Solved

SMO Error - Cannot Connect to Server

Posted on 2014-01-31
4
321 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

830 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