Brackets around Stored Procedure in ADODB Command Text
Help me understand why this is happening!
I use the ADODB.Command object. The Command Text is set to the Stored Procedure Name.
Sometimes, if I DON'T add brackets around the stored procedure name, I get a Syntax Error or Access Violation error.
Sometimes, if I DO add brackets around the stored procedure name, I get a Syntax Error or Access Violation error.
Code:
Dim objCmd As New ADODB.Command
With objCmd
.ActiveConnection = DBConnect()
.CommandText = "MyInsert"
.CommandType = adCmdStoredProc
.Parameters.Append
.CreateParameter("@MyId", adVarChar, adParamInput, 25, "123AB开发者_如何学编程C")
.Execute , , adExecuteNoRecords
End With
Set objCmd = Nothing
Can you post some code? The only time I've run into that error with ADO and VB6 is when passing a Guid argument as a string (rather than bound to a parameter) and when the string includes the {} around the Guid.
精彩评论