Loop Problem

Results 1 to 2 of 2

Thread: Loop Problem

  1. #1
    Margie Guest

    Default Loop Problem

    I am using a Loop to loop through records in my Record Set to match what a user has entered in a text box to a record in a DB - however the Loop is not only finding the record and returning the correct message it is also returning "Record does not match " message for every record in the DB that doesn&#039;t match what the user has entered in the textfield. How do I get the Loop to ignore all the other records and only return something when it&#039;s found the requested match?<BR><BR>The code is below:<BR>Dim objRS<BR>Set objRS = Server.CreateObject("ADODB.Recordset")<BR>objRS.op en "TestTable", objConn, 2, 3, adCmdTable<BR><BR>Do While Not objRS.EOF<BR>If objRS("StudentNumber") = request.form("StudentNumber") Then<BR>response.write "Well Done!"<BR>else <BR>response.write "Record does not match"<BR>End If<BR>objRS.MoveNext<BR>Loop<BR><BR><BR><BR>objRS. Close<BR>Set objRS = Nothing<BR><BR>objConn.Close<BR>Set objConn = Nothing<BR>

  2. #2
    Forum Police Guest

    Default CROSSPOST


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts