July 28, 2008 at 11:30 pm
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.
Viewing post 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy