• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

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.
0
aplusexpert
Asked:
aplusexpert
  • 2
  • 2
1 Solution
 
JimFiveCommented:
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

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now