N
Newbie
I have a stored procedure in SQL 2000 that is called with the following code
snippet This works fine from within SQL
When I try to execute the command I get the message:
Run-time error -2147217913
Error converting data type char to smalldatetime
If i strip everything out so that only the date parameters are in the SP it
works fine but as soon as I add another one in I get the above message.
All the variables are set as variant in Access
Here is the code
With cmdQuote
Set .ActiveConnection = cnMIS
.CommandText = "cerro_QuoteFollowUp"
.CommandType = adCmdStoredProc
Set params = .Parameters
End With
' Define stored procedure params and append to command.
params.Append cmdQuote.CreateParameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
params.Append cmdQuote.CreateParameter("@Classification", adChar,
adParamInput, 10)
params.Append cmdQuote.CreateParameter("@Customer", adVarChar, adParamInput,
7)
params.Append cmdQuote.CreateParameter("@DateFrom", adDBTimeStamp,
adParamInput, 0)
params.Append cmdQuote.CreateParameter("@DateTo", adDBTimeStamp,
adParamInput, 0)
params.Append cmdQuote.CreateParameter("@ProbFrom", adInteger, adParamInput)
params.Append cmdQuote.CreateParameter("@ProbTo", adInteger, adParamInput)
params.Append cmdQuote.CreateParameter("@Status", adChar, adParamInput, 1)
' Specify input parameter values
params("@DateFrom") = mDateFrom
params("@DateTo") = mDateTo
params("@Customer") = mCustomer
params("@Classification") = mClassification
params("@ProbFrom") = mProbFrom
params("@ProbTo") = mProbTo
params("@Status") = mStatus
' Execute the command
Set rsQuote = cmdQuote.Execute
And fYI here is the stored procedure:
CREATE PROCEDURE dbo.cerro_QuoteFollowUp
@DateFrom smalldatetime = NULL,
@DateTo smalldatetime = NULL,
@Customer varchar(7) = null,
@Classification char (10) = null,
@ProbFrom smallint = null,
@ProbTo smallint = null,
@Status char(1) = null
AS
SELECT QM.Quote,
CASE WHEN QM.QuoteStatus = '0' THEN 'Prep'
when QM.QuoteStatus = '1' then 'Ready for Print'
else 'Printed' end AS Stat,
QM.Classification,
QM.DateTenderReq,
QM.ProbabilityFlag,
QM.Customer,
QM.CustomerName,
QM.DateDeliveryReq,
QN.[Text],
QM.QuoteStatus
FROM QotMaster QM LEFT OUTER JOIN
QUHNotes QN ON QM.Quote = QN.KeyField
where QM.DateDeliveryReq >=@DateFrom and QM.DateDeliveryReq <=
coalesce(@DateTo,@DateFrom) and QM.Customer =
coalesce(@Customer,QM.Customer)
and QM.Classification = coalesce(@Classification,QM.Classification)
and QM.ProbabilityFlag >=@ProbFrom and QM.ProbabilityFlag <=
coalesce(@ProbTo,@ProbFrom)
and ((QM.QuoteStatus in('0','1','2')and @Status is null) or
(QM.QuoteStatus=@Status and @Status is not null))
GO
snippet This works fine from within SQL
When I try to execute the command I get the message:
Run-time error -2147217913
Error converting data type char to smalldatetime
If i strip everything out so that only the date parameters are in the SP it
works fine but as soon as I add another one in I get the above message.
All the variables are set as variant in Access
Here is the code
With cmdQuote
Set .ActiveConnection = cnMIS
.CommandText = "cerro_QuoteFollowUp"
.CommandType = adCmdStoredProc
Set params = .Parameters
End With
' Define stored procedure params and append to command.
params.Append cmdQuote.CreateParameter("@RETURN_VALUE", adInteger,
adParamReturnValue, 0)
params.Append cmdQuote.CreateParameter("@Classification", adChar,
adParamInput, 10)
params.Append cmdQuote.CreateParameter("@Customer", adVarChar, adParamInput,
7)
params.Append cmdQuote.CreateParameter("@DateFrom", adDBTimeStamp,
adParamInput, 0)
params.Append cmdQuote.CreateParameter("@DateTo", adDBTimeStamp,
adParamInput, 0)
params.Append cmdQuote.CreateParameter("@ProbFrom", adInteger, adParamInput)
params.Append cmdQuote.CreateParameter("@ProbTo", adInteger, adParamInput)
params.Append cmdQuote.CreateParameter("@Status", adChar, adParamInput, 1)
' Specify input parameter values
params("@DateFrom") = mDateFrom
params("@DateTo") = mDateTo
params("@Customer") = mCustomer
params("@Classification") = mClassification
params("@ProbFrom") = mProbFrom
params("@ProbTo") = mProbTo
params("@Status") = mStatus
' Execute the command
Set rsQuote = cmdQuote.Execute
And fYI here is the stored procedure:
CREATE PROCEDURE dbo.cerro_QuoteFollowUp
@DateFrom smalldatetime = NULL,
@DateTo smalldatetime = NULL,
@Customer varchar(7) = null,
@Classification char (10) = null,
@ProbFrom smallint = null,
@ProbTo smallint = null,
@Status char(1) = null
AS
SELECT QM.Quote,
CASE WHEN QM.QuoteStatus = '0' THEN 'Prep'
when QM.QuoteStatus = '1' then 'Ready for Print'
else 'Printed' end AS Stat,
QM.Classification,
QM.DateTenderReq,
QM.ProbabilityFlag,
QM.Customer,
QM.CustomerName,
QM.DateDeliveryReq,
QN.[Text],
QM.QuoteStatus
FROM QotMaster QM LEFT OUTER JOIN
QUHNotes QN ON QM.Quote = QN.KeyField
where QM.DateDeliveryReq >=@DateFrom and QM.DateDeliveryReq <=
coalesce(@DateTo,@DateFrom) and QM.Customer =
coalesce(@Customer,QM.Customer)
and QM.Classification = coalesce(@Classification,QM.Classification)
and QM.ProbabilityFlag >=@ProbFrom and QM.ProbabilityFlag <=
coalesce(@ProbTo,@ProbFrom)
and ((QM.QuoteStatus in('0','1','2')and @Status is null) or
(QM.QuoteStatus=@Status and @Status is not null))
GO