Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using recordsets for searching?

Status
Not open for further replies.

beardawg

Programmer
Dec 13, 2000
1
US
I am trying to use a recordset to search for a record in a database. By passing a sql statement to the recordset, requerying, and then checking to see if it is empty. For example.

sqlString = "select * from dbo.EM where emLastName = '"& LastName & "'"
Recordset2.setSQLText(sqlString)
Recordset2.requery

if Recordset2.getCount() = 0 then
Response.Redirect("first_page.asp?Result=Failed")
End if

Correct me if I am wrong, but shouldn't this recordset be empty if LastName does not exist? Any suggestions on a better way to approach this?
 
Assuming you are working with a DTC.Recordset object, you might try doing this: ( Javascript )

if ( !Recordset1.getRecordSource().EOF)
Recordset1.getRecordSource().Filter = "emLastName like 'R%'";

while( !Recordset1.getRecordSource().EOF){
.... rest of your stuff
}

Hope this helps
-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top