Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

SQLDMO.ExecuteWithResultsAndMessages2 Method Expand / Collapse
Author
Message
Posted Monday, July 28, 2008 11:30 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, May 26, 2009 3:51 AM
Points: 7, Visits: 33
I Used SQLServer 2000/2005 with VB 6.0. I used SQLDMO in My Application.

I try to Execute a batch script with SQLServer2.ExecuteWithResultsAndMessages2 method. but every time i got error message "incorrect syntax near 'GO'"

Full Code is:

Dim sSqlServer As New SQLDMO.SQLServer2
Dim sDatabase As SQLDMO.Database2
Dim qResult As SQLDMO.QueryResults2
Dim sMsg As String
Dim sCommand As String


Call sSqlServer.Connect("Server", "UID", "PWD")

Set sDatabase = sSqlServer.Databases("MyDB")

sCommand = "/*MyScript.SQL*/" & vbCrLf
sCommand = sCommand & "SET NOCOUNT ON" & vbCrLf
sCommand = sCommand & "SELECT * FROM MyTable" & vbCrLf
sCommand = sCommand & "Print Cast(@@RowCount As VarChar) + ' Record(s) Found'" & vbCrLf
sCommand = sCommand & "SET NOCOUNT OFF" & vbCrLf
sCommand = sCommand & " GO"

Set qResult = sDatabase.ExecuteWithResultsAndMessages2(sCommand, sMsg, Len(sCommand))

Msgbox sMsg
Msgbox qResult.Rows



Pls any one solve my problem.
Post #542362
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse