0

I want to Deploy C# application with SQL database. I am using database scripts in MSI insataller. My database scripts working fine on DBCC (database console command) of SQL server 2005 management studio. But while executing "ExecuteNonQuery" in installer it gives exception shown in screen shot. enter image description here

How can I resolve it? I am using following connection string.

                    connString = "Data Source = " + machineName + "\\SQLEXPRESS; Initial Catalog = master; Integrated Security = SSPI";
3
  • Can you post the query that is being executed? Looks like the query is syntactically not correct. Commented Dec 3, 2011 at 7:02
  • This query working fine if I execute it on SQL server. Commented Dec 3, 2011 at 7:04
  • i hope people can help you better if you post your code & query along with this exception screenshot. Commented Dec 3, 2011 at 8:09

4 Answers 4

2

You can't use the 'GO' command inside of a SqlCommand like that. Here's a good explanation and a few workarounds:

http://weblogs.asp.net/jgalloway/archive/2006/11/07/Handling-_2200_GO_2200_-Separators-in-SQL-Scripts-2D00-the-easy-way.aspx

Sign up to request clarification or add additional context in comments.

Comments

1

Place semicolon (;) after each GO statement, or even better each statement. When using DML statements, SQL Server accepts them without semicolons, but when using GO you have to delimit them.

Comments

1

Have a look on this;

http://smehrozalam.wordpress.com/2009/05/12/c-executing-batch-t-sql-scripts-with-go-statements/

Comments

0

Replace go with new line (\r\n). That will run all the commands in the string var in sequence.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.