I use vb 6.0 to do a front-end application which calls a store procedure in SQL Server. The store procdure will insert the data that get from VB User interface and return a number to VB.

I create a adodb.command object in command button click event procedure. The store procedure runs correct and the vb gets the correct data back, but when the command is set to nothing, I get a message From T-SQL debugger:


" THe query could not be debugger due to a problem coordinating events withthe server. Check the server and client log to find the exact cause, fix the problem and try again."

My code is look like the following:


cmdSubmit_Click()
dim cn as string
cn = "ODBC;....DRIVER={SQL Server};"

Dim cm As New ADODB.Command
Dim p As New ADODB.Parameter

With cm
.ActiveConnection = cn
.CommandType = adCmdStoredProc
.CommandText = "Servername..Insert_Staff"
End With

Set p = cm.CreateParameter(, adChar, adParamInput, 3) ' unitid
cm.Parameters.Append p
p.Value = txtUnitid.Text

'..... create more input paramerters
' and one output parameter

cm.Execute
txtstaffid = cm.Parameter(14).Value
'parameter(14) is a output parameter

Set p = Nothing
Set cm = Nothing 'this is where I got the message

end sub

Thanks in advance.