July 28, 2008 at 11:47 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.
July 29, 2008 at 4:13 am
Please don't cross post. It just wastes people's time and fragments replies. Many of us read all the forums.
No replies to this thread please. Direct replies to :
http://www.sqlservercentral.com/Forums/Topic542367-9-1.aspx
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply