Forums

This topic is locked

The best way to get num of records in a recordset

Posted 21 Sep 2001 19:19:48
1
has voted
21 Sep 2001 19:19:48 B. B. posted:
What is the best way to check if a record already exists on a database table? For example, have a site that has an Insert page in addition to the update page. The users must insert a record first before using the
update page.

Have a check on the Insert page which
defines a recordset which performs a selection based on the Username on the User table. If they do have a record on the Winners_Table, they should only have one, then the Insert page will redirect to an error page indicating that fact and it contains a link that they need to go to the update page.

The number of records returned from the recordset which selects from the
Winners_table is determined as follows.

If rsChAlreadyInp.EOF Then
Response.Redirect("already_insertpick.asp"
Else
%>
<%
' *** Insert Record: set variables - the Insert behavior code follows here

Is the recordset.EOF the best way to check or should some of the other recordset parameters be used such as the following.

rsChAlreadyInp_first = 1, or rsChAlreadyInp_last, or
rsChAlreadyInp_numRows - 1 or finally
rsChAlreadyInp_total.

Have found this in some of the code that is built but not sure which parameter needs to be checked. Thanks!


Reply to this topic