J
Joss
PLease help. I am trying to return a variable from a stored procedure but
banging my head against the wall tryingto get passed this error. I can see
from looking at many groups that it is a common problem but cannot see where
my code is wrong. The procedure should return one value which I can then use
in the code to update a form control, but, I keep getting 'Parameter object
is improperly defined.Incomplete or inconsistent information was provided.
Have tried using varchar instead of nvarchar and various cominations in the
brackets, but no good. If somebody can turn the light on it would be
appreciated.
thanks,
Jo
Dim cmd As New ADODB.Command
Dim prm As ADODB.Parameter
Dim faxout As String
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spcontactNo"
Set prm = cmd.CreateParameter("@faxno", adNvarChar, adParamOutput, 20, "")
'something wrong in this line. Tried many variations of parameters.
cmd.Parameters.Append prm
cmd.Execute
faxout = cmd.Parameters(1).value
MsgBox faxout
Alter procedure spContactNo
@faxno nvarchar(20) OUTPUT
as
Select @faxno = contFax
FROM dbo.tblContacts
where contCustomerCode= 'CUSTOMER'
return @faxno;
banging my head against the wall tryingto get passed this error. I can see
from looking at many groups that it is a common problem but cannot see where
my code is wrong. The procedure should return one value which I can then use
in the code to update a form control, but, I keep getting 'Parameter object
is improperly defined.Incomplete or inconsistent information was provided.
Have tried using varchar instead of nvarchar and various cominations in the
brackets, but no good. If somebody can turn the light on it would be
appreciated.
thanks,
Jo
Dim cmd As New ADODB.Command
Dim prm As ADODB.Parameter
Dim faxout As String
Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "spcontactNo"
Set prm = cmd.CreateParameter("@faxno", adNvarChar, adParamOutput, 20, "")
'something wrong in this line. Tried many variations of parameters.
cmd.Parameters.Append prm
cmd.Execute
faxout = cmd.Parameters(1).value
MsgBox faxout
Alter procedure spContactNo
@faxno nvarchar(20) OUTPUT
as
Select @faxno = contFax
FROM dbo.tblContacts
where contCustomerCode= 'CUSTOMER'
return @faxno;