Solved

SMO Error - Cannot Connect to Server

Posted on 2014-01-31
4
312 Views
Last Modified: 2014-06-25
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
Comment
Question by:aplusexpert
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
JimFive earned 500 total points
ID: 39824152
GO is not a valid SQL statement, it works in Management Studio but not elsewhere, replace all of your "GO" with ;
0
 
LVL 7

Author Comment

by:aplusexpert
ID: 39829292
Hey JimFive. Thanks for your response.


I have replace all "GO" Statement with ";". but Still i am getting the Same Error.
0
 
LVL 15

Expert Comment

by:JimFive
ID: 39829751
What is the actual value of ScriptText?
0
 
LVL 7

Author Closing Comment

by:aplusexpert
ID: 40158881
Partial Solution. didn't really work in our case
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now