{"id":3398,"date":"2014-03-24T01:26:17","date_gmt":"2014-03-24T01:26:17","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/24\/create-sql-script-with-visual-studio-2012-at-c-and-how-run-it-collection-of-common-programming-errors\/"},"modified":"2014-03-24T01:26:17","modified_gmt":"2014-03-24T01:26:17","slug":"create-sql-script-with-visual-studio-2012-at-c-and-how-run-it-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/24\/create-sql-script-with-visual-studio-2012-at-c-and-how-run-it-collection-of-common-programming-errors\/","title":{"rendered":"create .sql script with Visual Studio 2012 at c# and how run it?-Collection of common programming errors"},"content":{"rendered":"<p>I have a little problem about that. When i create a script with VS2012 ,it looks like that (DataBase Name : LSProjeDB and have a table as Musteri) (created like that : go table &gt; update&gt;genarete script &gt;wow)<\/p>\n<pre><code>GO SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON;\nSET NUMERIC_ROUNDABORT OFF;\nGO\n:setvar DatabaseName \"C:\\USERS\\YC\\DOCUMENTS\\LSPROJEDB.MDF\"\n:setvar DefaultFilePrefix \"C_\\USERS\\YC\\DOCUMENTS\\LSPROJEDB.MDF_\"\n:setvar DefaultDataPath \"C:\\Users\\YC\\AppData\\Local\\Microsoft\\Microsoft SQL Server Local DB\\Instances\\v11.0\\\"\n:setvar DefaultLogPath \"C:\\Users\\YC\\AppData\\Local\\Microsoft\\Microsoft SQL Server Local DB\\Instances\\v11.0\\\"\nGO\n:on error exit\nGO\n\n\/*\nDetect SQLCMD mode and disable script execution if SQLCMD mode is not supported.\nTo re-enable the script after enabling SQLCMD mode, execute the following:\nSET NOEXEC OFF; \n*\/\n\n\n:setvar __IsSqlCmdEnabled \"True\"\nGO\nIF N'$(__IsSqlCmdEnabled)' NOT LIKE N'True'\n    BEGIN\n        PRINT N'SQLCMD mode must be enabled to successfully execute this script.';\n        SET NOEXEC ON;\n    END\nGO\nUSE [$(DatabaseName)];\nGO\nPRINT N'Update complete.'\nGO\n<\/code><\/pre>\n<p>but it is looks like wrong!! and i used that c# code :<\/p>\n<pre><code> string str = \"DataSource=(local);Initial Catalog=DatabaseName ;Integrated Security=True\";\n        FileInfo file = new FileInfo(\"D:\\\\SQLQuery2.sql\");\n        string script = file.OpenText().ReadToEnd();\n        SqlConnection conn = new SqlConnection(str);\n        Server server = new Server(new ServerConnection(conn));\n        server.ConnectionContext.ExecuteNonQuery(script);\n<\/code><\/pre>\n<p>and i got :<\/p>\n<blockquote>\n<p>ArgumentException is unhandled! Keyword not supported: &#8216;datasource&#8217;.<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>I have a little problem about that. When i create a script with VS2012 ,it looks like that (DataBase Name : LSProjeDB and have a table as Musteri) (created like that : go table &gt; update&gt;genarete script &gt;wow) GO SET ANSI_NULLS, ANSI_PADDING, ANSI_WARNINGS, ARITHABORT, CONCAT_NULL_YIELDS_NULL, QUOTED_IDENTIFIER ON; SET NUMERIC_ROUNDABORT OFF; GO :setvar DatabaseName &#8220;C:\\USERS\\YC\\DOCUMENTS\\LSPROJEDB.MDF&#8221; :setvar [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3398","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3398"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3398\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}