I'm having a heck of a time trying to create a parameterized query that binds a date variable into a stored procedure call:
twoyearsago = dateadd("yyyy", -2, date())
DataConn.ConnectionString = myConnectionString
DataConn.Open
Set rs = Server.CreateObject("ADODB.Recordset")
Set DataCmd = Server.CreateObject("ADODB.Command")
DataCmd.ActiveConnection = DataConn
DataCmd.CommandText = "exec myStoredProc ?, ?"
DataCmd.Parameters.Append DataCmd.CreateParameter("@start", adDate, , 10, date())
DataCmd.Parameters.Append DataCmd.CreateParameter("@end", adDate, , 10, twoyearsago)
rs.Open DataCmd
The stored proc returns nothing (indicating the dates aren't making it through). If I hard code dates in the query, e.g.:
DataCmd.CommandText = "exec myStoredProc '01/01/2008', '01/01/2010'"
I get the results I would expect. Calling CStr on my dates (if that makes a difference) returns them in the above format.