Solved

SMO Error - Cannot Connect to Server

Posted on 2014-01-31
4
336 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

624 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