General information
Category:
Database DAO/RDO/ODBC/ADO
Noel,
Your missing something in your code.
The following is the part of your code that I have extracted.
objCon.Open ConnectionString
objCmd.ActiveConnection = objCon
objCmd.CommandText = "qrySALES"
objCmd.CommandType = adCmdStoredProc
Set objPar = objCmd.CreateParameter("DATE", adDBDate, adParamInput, 12, txtDateFrom)
objCmd.Parameters.Append objPar
Set objPar = objCmd.CreateParameter("DATE", adDBDate, adParamInput, 12, txtDateTo)
objCmd.Parameters.Append objPar
Set objRst = objCmd.Execute
Note that CreateParameter function you supply the same
parameter name which is CreateParameter("DATE",....).
Take a look on your code your using "DATE" and "DATE" parameter.
May be it should be "DATE1" and "DATE2" respectively.
You need to supply the name of your parameter correctly.
Do not use the same name of the query parameter.
example you have the following access query:
PARAMETERS param1 Text ( 255 ), param2 Text ( 255 );
SELECT Tbl1.field1, Tbl1.field2
FROM Tbl1
WHERE Tbl1.field1 = param1 and Tbl1.field2 = param2;
your VB code must like this.
Set objPar = objCmd.CreateParameter("param1", adDBDate, adParamInput, 12, txtDateFrom)
objCmd.Parameters.Append objPar
Set objPar = objCmd.CreateParameter("param2", adDBDate, adParamInput, 12, txtDateTo)
objCmd.Parameters.Append objPar
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only