Displaying recordset value if it's there

J

Joey Martin

I have a Stored Procedure that displays results based on the parameters.
If someone enters bad parameters, it will pass back a fieldname
"ERRORDESC". 99% of the time this field will not exist in my recordset.
But, is there a way to check to see if that field is being returned?

Again, most of the time, the recordset fields passed to me will not
include that field.

Just curious is this is possible.
 
B

Bob Barrows

Joey said:
I have a Stored Procedure that displays results based on the
parameters. If someone enters bad parameters, it will pass back a
fieldname "ERRORDESC". 99% of the time this field will not exist in
my recordset. But, is there a way to check to see if that field is
being returned?

Again, most of the time, the recordset fields passed to me will not
include that field.

Just curious is this is possible.
It's possible (loop through the recordset's Fields collection), but it's
not really good practice. You should return a consistent resultset.

My preference would be to use an output parameter for this purpose but
that would complicate the code, requiring an explicit Command object and
code to build the Parameters collection.
Second best would be to return two recordsets: the first containing the
ERRORDESC field. Your code would read the content of the field, and if
it contains "No Problem" or Null (whatever you have your stored
procedure put into it when the parameters are good), use "Set
rs=rs.NextRecordset" to retrieve the second recordset and process it.
Third best would be to always return the ERRORDESC field, only
populating it if there is a problem

But more important, I would try to validate the inputs before sending
them to the database, if possible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top