(Previously posted in SQL forum)
I am trying to execute a simple select query in an ADP file via code and I’m getting an error message saying the sproc has “too many arguments specified”. It’s a very simple query and I don’t see what I’m doing wrong. "Com" is my command object variable and "Con" is my connection object variable, both of which are working fine. I've searched the FAQs but found nothing. Thanks!
Code:
With Com
.ActiveConnection = Con
.CommandType = adCmdStoredProc
.CommandText = "dbo.MyProcedureName"
.Parameters.Append .CreateParameter("@Parameter", adVarChar, adParamInput, 9, Trim(FormField.Value))
End With
Set MyRecordset = Com.Execute
Sproc:
CREATE PROCEDURE dbo.MyProcedureName
@Parameter varchar(9)
AS
SELECT Field
FROM dbo.Table
WHERE (Field = @Parameter)
GO
I am trying to execute a simple select query in an ADP file via code and I’m getting an error message saying the sproc has “too many arguments specified”. It’s a very simple query and I don’t see what I’m doing wrong. "Com" is my command object variable and "Con" is my connection object variable, both of which are working fine. I've searched the FAQs but found nothing. Thanks!
Code:
With Com
.ActiveConnection = Con
.CommandType = adCmdStoredProc
.CommandText = "dbo.MyProcedureName"
.Parameters.Append .CreateParameter("@Parameter", adVarChar, adParamInput, 9, Trim(FormField.Value))
End With
Set MyRecordset = Com.Execute
Sproc:
CREATE PROCEDURE dbo.MyProcedureName
@Parameter varchar(9)
AS
SELECT Field
FROM dbo.Table
WHERE (Field = @Parameter)
GO