The following Access Application works fine when I pass 1 parameter at a time to the stored proc. When I pass 2 parms at the same time the parameters get loaded as per the following Immediate Window values:
?RptYearF
2005
?RptYearS
2004
For the snapshots of my code, you will see that I commented out the code for 1 of the parameters to prove that the application runs fine when I run the application with just 1 parameter.
However, the application blows up on the following line:
Set rstQueryFS = .Execute
?err.Number
-2147217900
--------------------------------
How can I modify the application or stored procedure to handle the 2 parameters in the stored procedure ?
With com
.CommandType = adCmdStoredProc
.CommandText = "dbo.procUDFl"
.Parameters.Refresh
Set prmSQL = .CreateParameter("@prmSQL", adVarChar, adParamInput, 8000, strSQLFS)
.Parameters.Append prmSQL
'Set RptYearF = .CreateParameter("@RptYearF", adInteger, adParamInput, 4, intYearSP)
'.Parameters.Append RptYearF
Set RptYearS = .CreateParameter("@RptYearS", adInteger, adParamInput, 4, intYearSPS)
.Parameters.Append RptYearS
.ActiveConnection = cn
Set rstQueryFS = .Execute
End With
CREATE PROCEDURE dbo.procUDFl
@prmSQL varchar (8000),
--@RptYearF int
@RptYearS int
AS
--SET @prmSQL = REPLACE(@prmSQL,'intYearSP',CAST(@RptYearF AS CHAR(4)))
SET @prmSQL = REPLACE(@prmSQL,'intYearSPS',CAST(@RptYearS AS CHAR(4)))
EXEC( @prmSQL)
GO
------------------
prmSQL is a dynamics SQL string that I create in an Access Application and pass to the Stored Procedure for execution.
?RptYearF
2005
?RptYearS
2004
For the snapshots of my code, you will see that I commented out the code for 1 of the parameters to prove that the application runs fine when I run the application with just 1 parameter.
However, the application blows up on the following line:
Set rstQueryFS = .Execute
?err.Number
-2147217900
--------------------------------
How can I modify the application or stored procedure to handle the 2 parameters in the stored procedure ?
With com
.CommandType = adCmdStoredProc
.CommandText = "dbo.procUDFl"
.Parameters.Refresh
Set prmSQL = .CreateParameter("@prmSQL", adVarChar, adParamInput, 8000, strSQLFS)
.Parameters.Append prmSQL
'Set RptYearF = .CreateParameter("@RptYearF", adInteger, adParamInput, 4, intYearSP)
'.Parameters.Append RptYearF
Set RptYearS = .CreateParameter("@RptYearS", adInteger, adParamInput, 4, intYearSPS)
.Parameters.Append RptYearS
.ActiveConnection = cn
Set rstQueryFS = .Execute
End With
CREATE PROCEDURE dbo.procUDFl
@prmSQL varchar (8000),
--@RptYearF int
@RptYearS int
AS
--SET @prmSQL = REPLACE(@prmSQL,'intYearSP',CAST(@RptYearF AS CHAR(4)))
SET @prmSQL = REPLACE(@prmSQL,'intYearSPS',CAST(@RptYearS AS CHAR(4)))
EXEC( @prmSQL)
GO
------------------
prmSQL is a dynamics SQL string that I create in an Access Application and pass to the Stored Procedure for execution.