Hello,
I'm posing to this group because I need some help with an issue I'm
encountering opening an ADO Recordset.
Posted below is the code that I am using to open the Recordset
Set rsReportData = Server.CreateObject("ADODB.RecordSet")
rsReportData.CursorLocation = adUseClient
rsReportData.CursorType = adOpenStatic
Set reportObj = Server.CreateObject("ADODB.Command")
With reportObj
.CommandTimeout = 120
.ActiveConnection = cnnData
.CommandType = adCmdStoredProc
.commandText = "usp_ARSReport_InboundPassangerSummary"
.Parameters.Append
reportObj.CreateParameter("@StartDate",adDate,adParamInput,,StartDate)
.Parameters.Append
reportObj.CreateParameter("@EndDate",adDate,adParamInput,,EndDate)
End With
rsReportData.Open reportObj
^^^^^ This is where the problem rears its ugly head. The stored
procedure always returns records when I run it through query analyzer
however when I try and pass some dates the recordset refuses to open.
The connection is valid, and if I run the stored proc through query
analyzer with the dates causing the error it returns data so I'm not
sure where the problem is comming from. I also thought that the data
I'm passing through to the param argument was invalid but I tried
sending through as CDate(startdate) & CDate(enddate) and it still
failed. Perhaps the strangest part about this is that it produces no
error. ANY help tracking this bug down is greatly appreciated!
Dylan Finney
dylanfinney@gmail.com - 31 May 2006 20:42 GMT
I have cleared up this problem. Although I had the following in place
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
as well as
SET NOCOUNT ON
in the stored procedure, error messages returned by aggregate or other
SET operations are returned as well as the recordset. This causes no
ADO errors to be thrown but will not allow the recordset object to be
opened. I corrected the problem in the stored procedure bu using
IsNull and the Coalesce functions.
Hopefully if anyone else encounters this type of problem these posts
will help.