SMO Error - Cannot Connect to Server

Hello Friends,

I have SQL Script File for Creating Whole database.

I want to execute that "Script" file from my c# application.So I used SMO Object for it. But some how it is giving me error that "could not connect to the server".

I have also tried SqlHelper.ExecuteNonQuery(ScriptText). but throws error that
"Incorrect Systax near GO Statement"

Note that this same query is WORKING fine while executing direct from SQL SERVER. So, No Errors in Script File.

I am using SQL SERVER 2008 R2.

I also want to know the same logic will work in SQL SERVER 2005 ?

Please feel free to ask in case of any query

Thanks In Advance.
LVL 7
aplusexpertAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
JimFiveConnect With a Mentor Commented:
GO is not a valid SQL statement, it works in Management Studio but not elsewhere, replace all of your "GO" with ;
0
 
aplusexpertAuthor Commented:
Hey JimFive. Thanks for your response.


I have replace all "GO" Statement with ";". but Still i am getting the Same Error.
0
 
JimFiveCommented:
What is the actual value of ScriptText?
0
 
aplusexpertAuthor Commented:
Partial Solution. didn't really work in our case
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.