Hi, I've been working as a semi-pro (very "semi" in what matters) access programmer here in Brazil for a couple of years now and I am considering upgrading one client's database to MSDE/Access Project. I'm facing many problems, however. Maybe the more serious by now is that I cannot manage to pass parameters to Stored Procedures in VB code.
I have a stored procedure like this:
------------------------------------------
ALTER PROCEDURE dbo.agentesqry
@codigo varchar(12)
AS SELECT dbo.Agentes.*
FROM dbo.Agentes
WHERE (CODICE = @codigo)
------------------------------------------
Somewhere in my code I try the following:
---------------------------------------------
dim adoConnection As New ADODB.Connection
dim adoRecordset As New ADODB.Recordset
dim adoCommand As New ADODB.Command
dim adoPar As New ADODB.Parameter
adoConnection.Open _
CurrentProject.Connection.ConnectionString
Set adoCommand.ActiveConnection = adoConnection
adoCommand.CommandText = "agentesqry"
Set adoPar = adoCommand.CreateParameter _
("@codigo",adVarChar, adParamInput, 12, "2030061"
adoCommand.Parameters.Append adoPar
adocommand.execute
adoRecordset.Open adoCommand
---------------------------------------------------------
but IT DOESN'T WORK!!! The following message appears:
"Procedure 'agentesqry' expects parameter '@codigo', which is not supplied."
When I put the stored procedure as RecordSource of a form and put the parameter value in the InputParameter property it works fine. I whant the code above so that I can put everything in a "begintrans".
I hope someone can show me what I'm doing wrong.
I have a stored procedure like this:
------------------------------------------
ALTER PROCEDURE dbo.agentesqry
@codigo varchar(12)
AS SELECT dbo.Agentes.*
FROM dbo.Agentes
WHERE (CODICE = @codigo)
------------------------------------------
Somewhere in my code I try the following:
---------------------------------------------
dim adoConnection As New ADODB.Connection
dim adoRecordset As New ADODB.Recordset
dim adoCommand As New ADODB.Command
dim adoPar As New ADODB.Parameter
adoConnection.Open _
CurrentProject.Connection.ConnectionString
Set adoCommand.ActiveConnection = adoConnection
adoCommand.CommandText = "agentesqry"
Set adoPar = adoCommand.CreateParameter _
("@codigo",adVarChar, adParamInput, 12, "2030061"
adoCommand.Parameters.Append adoPar
adocommand.execute
adoRecordset.Open adoCommand
---------------------------------------------------------
but IT DOESN'T WORK!!! The following message appears:
"Procedure 'agentesqry' expects parameter '@codigo', which is not supplied."
When I put the stored procedure as RecordSource of a form and put the parameter value in the InputParameter property it works fine. I whant the code above so that I can put everything in a "begintrans".
I hope someone can show me what I'm doing wrong.