Results 1 to 3 of 3

Thread: Loop until found result problem?

  1. #1

    Thread Starter
    Join Date
    Jan 2006

    Question Loop until found result problem?

    Good morning,

    I am trying to loop through an Access database via VB6 and am having problems. I am connecting to the Access database fine with no problems, What I am searching for is a username which is being held in a global string when the user logs in. I want this username to be searched for within a table called tblAdmin and if it there then I can carry on from there...

    I have had a good search through the site and can not find anything near what I am looking for... Can anyone please give me a hand?


  2. #2
    VB Guru ganeshmoorthy's Avatar
    Join Date
    Dec 2005
    Sharjah, United Arab Emirates

    Re: Loop until found result problem?

    VB Code:
    1. Dim rsDisplay As ADODB.Recordset
    3. Set rsDisplay = New ADODB.Recordset
    4. Sql = Select * From tblAdmin Where UserName = '" & strUserName & "'"
    5. rsDisplay.Open Sql, Cn, adOpenDynamic, adLockOptimistic
    6. If Not rsDisplay.EOF Then
    7.     'do your codings
    8. End If
    9. rsDisplay.Close
    replace strUserName with your global variable which contains the user name
    If an answer to your question has been helpful, then please, Rate it!

    Have done Projects in Access and Member management systems using BioMetric devices, Smart cards and BarCodes.

  3. #3
    Shared Member
    Join Date
    May 2005
    Kashmir, India

    Re: Loop until found result problem?

    You don't have to search through the database. Once you have a connection open to your database, you just have to execute a query using a Where condition. Say your connection object is dbCon, then you can write this code to check if the username exists in the database.
    VB Code:
    1. Dim rsUser As ADODB.Recordset
    2. Set rsUser = New ADODB.Recordset
    4. rsUser.Open "Select * From USERTABLE Where USERNAME = '" & gUserName & "'", dbCon, adOpenDynamic
    6. If rs.User.EOF Then
    7.    'the user does not exist in the database, exit
    8. Else
    9.    'User Exists continue logging on
    10. End If
    Use [code] source code here[/code] tags when you post source code.

    My Articles

Posting Permissions

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

Click Here to Expand Forum to Full Width