Article ID: 183008
Article Last Modified on 3/2/2005
Dim con As New Connection
Dim cmd As New Command
con.Open "DSN=YourDSN;database=YourDatabase;Username=<username>;PWD=<strong password>;"
' Drop stored procedure, but ignore error if it doesn't exist.
On Error Resume Next
con.Execute "drop procedure proctest"
' Restore error handling.
On Error GoTo 0
' Create stored procedure that has return and input parameter.
con.Execute "create procedure proctest(@in text) as return 1"
Set cmd.ActiveConnection = con
cmd.CommandText = "{? = call proctest(?)}"
cmd.Parameters.Refresh
' At this point parameter 0's direction is indicated to be Output (adParamOutput, 2),
' when in fact it is return (adParamReturnValue, 4).
' Parameter 1's direction is correctly
' set to be an input parameter (1). Even so, this code executes
' as is at this point.
Msgbox "Cmd(0).Direction: " & cmd(0).Direction
Msgbox "Cmd(1).Direction: " & cmd(1).Direction
' Uncommenting this line will make the test work fine.
' cmd(0).Direction = adParamReturnValue
cmd(1).Type = adLongVarChar ' Bug only occurs with this line
cmd(1).Value = "Some String"
cmd.Execute '<<error here
Keywords: kbbug kbfix kbmdac270fix kbstoredproc kbado270fix kbdatabase KB183008