This (If Not objRS.EOF Then) would actually fail if no records are returned
from objConn.Execute().  However, using the Recordset Open as in his posted,
code, the recordset WILL exist and be "open", regardless of whether any rows
were returned.

HTH,
Tore.


----- Original Message -----
From: "Ken Schaefer" <[EMAIL PROTECTED]>
To: "ActiveServerPages" <[EMAIL PROTECTED]>
Sent: Thursday, November 07, 2002 8:16 PM
Subject: Re: Error control


> What's wrong with:
>
> (changed RecordExists to be a boolean, and not selecting the entire record
> anymore, just one field - you should change this to be the fields you
> actually need)
>
> =========
> Dim strSQL
> Dim blnRecordExists
>
> blnRecordExists = False
> strSQL = "SELECT DeliverableID FROM tbl_deliverables WHERE record_id = 5
AND
> deliverable_id = 2"
>
> Set objRS = objConn.Execute(strSQL0
> If not objRS.EOF then
>     blnRecordExists = True
> End If
> ============
>
> Cheers
> Ken
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ----- Original Message -----
> From: "Johnny Martinez" <[EMAIL PROTECTED]>
> To: "ActiveServerPages" <[EMAIL PROTECTED]>
> Sent: Friday, November 08, 2002 12:04 PM
> Subject: RE: Error control
>
>
> : This is an ASP page.
> :
> : The problem is that if I open the recordset with that SQL statement and
> the
> : record doesn't exist...boom. I can't even attempt objRecordCheck.eof
until
> I
> : successfully open the recordset.
> :
> : J
> :
> : -----Original Message-----
> : From: EXT-Sauceda, Gilbert [mailto:gilbert.sauceda@;boeing.com]
> : Sent: Thursday, November 07, 2002 4:40 PM
> : To: ActiveServerPages
> : Subject: RE: Error control
> :
> :
> : You've got VBscript and SQL code all mixed up together.
> : Is this in a stored procedure, or ASP page?
> :
> : If it's on an ASP page and all you want to check is if anything got
> : returned, then you could simply check if the recordset returned is
> empty...
> :
> : if NOT objRecordCheck.eof then
> : strRecordExists = 1
> : end if
> :
> : -----Original Message-----
> : From: Johnny Martinez [mailto:jmartinez@;tmi-la.com]
> : Sent: Thursday, November 07, 2002 3:11 PM
> : To: ActiveServerPages
> : Subject: Error control
> :
> :
> : I'm trying to check the DB for a valid record.
> :
> : How I'm handling it now is by spinning through the table and doing
record
> id
> : AND comparisons then setting a record exists flag to true.
> :
> : I think I have seen better code for this in the past.
> :
> : Can I just attempt to access the record directly and if the action
> succeeds
> : set the flag to true?
> : My problem is I don't know what to replace EXISTS with.
> :
> : Johnny
> :
> : =========
> : Dim strSQL
> : Dim strRecordExists
> :
> : strRecordExists = 0
> : strSQL = "SELECT * FROM tbl_deliverables WHERE record_id = 5 AND
> : deliverable_id = 2"
> :
> : If (EXISTS(objRecordCheck.Open strSQL, objConn)) Then
> :   strRecordExists = 1
> : End If
> : ============
> :
> :
> : ---
> : You are currently subscribed to activeserverpages as:
> : [EMAIL PROTECTED]
> : To unsubscribe send a blank email to
> : %%email.unsub%%
> :
> : ---
> : You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
> : To unsubscribe send a blank email to
> : %%email.unsub%%
> :
> : ---
> : You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
> : To unsubscribe send a blank email to
> %%email.unsub%%
>
>
> ---
> You are currently subscribed to activeserverpages as:
[EMAIL PROTECTED]
> To unsubscribe send a blank email to
%%email.unsub%%
>


---
You are currently subscribed to activeserverpages as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]

Reply via email to