Re: Error reading recordset from DB2/AS400
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Tue, 11 Sep 2007 12:00:33 -0400
ShaggyMoose wrote:
Set adorecSet= _
adoConn.Execute("{Call libraryname.PR_TEST()}", ,adCmdText)
Thanks for you help. I tried the above, and it called the stored
procedure and returned a record set. However, there are two problems:
1. The cursor doesn't seem to know the record count (eg.
adoRecSet.RecordCount = -1).
Why is this a big deal? There are other ways to determine record count.
One way is to use an output parameter to return the count - I'm not sure
of the syntax to do this in AS400 procedures, but I'm pretty sure it is
possible. Of course, this technique will require the use of an explicit
Command object to deal with the parameter.
Another way is to use GetRows to dump the recordset's data into a
2-dimensional array and using Ubound to determine the record count. A
side benefit of doing this is that you are able to close the recordset
and database connection sooner, because the data is in the array.
If you really need the recordset, then use a client-side cursor:
adoconn.CursorLocation = adUseClient
adoConn.Execute("{Call libraryname.PR_TEST()}", ,adCmdText)
I would suggest disconnecting this recordset while processing it so the
connection can be closed.
2. I still get the same error message on the first adDBDate field when
the value is not NULL.
I would modify the sql statement in the procedure to use COALESCE to
make sure Nulls were not returned, substituting an impossible date
(99991231 for example) for the Nulls (this will require that you specify
the fields to be returned, but doiing so is really good programming
practice anyways. "Select *" should be avoided in production code):
SELECT COALESCE(datefield,99991231) as datefield, ...
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
.
- Follow-Ups:
- Re: Error reading recordset from DB2/AS400
- From: ShaggyMoose
- Re: Error reading recordset from DB2/AS400
- References:
- Error reading recordset from DB2/AS400
- From: ShaggyMoose
- Re: Error reading recordset from DB2/AS400
- From: Stephen Howe
- Re: Error reading recordset from DB2/AS400
- From: ShaggyMoose
- Re: Error reading recordset from DB2/AS400
- From: Bob Barrows [MVP]
- Re: Error reading recordset from DB2/AS400
- From: ShaggyMoose
- Error reading recordset from DB2/AS400
- Prev by Date: Re: Error reading recordset from DB2/AS400
- Next by Date: Re: Error reading recordset from DB2/AS400
- Previous by thread: Re: Error reading recordset from DB2/AS400
- Next by thread: Re: Error reading recordset from DB2/AS400
- Index(es):