Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Looking up from database and validating (VB6)

    Ok, I'm wondering how to do this. Not a total necessity but something that could be useful in the future for what I am doing. Anyway I am wondering how I would go about setting something up where it reads a table in a database that has a few different fields in it, and if the information entered is a match with all fields then it would do something.

    A good example off the top of my head would be like a user ID and password look up. If you enter such and such ID and password it will do some action if The password in the Password field is in the same row with the ID. So I guess a good drawing would be something like this.

    User ID_____Password
    user1_______hello
    user2_______goodbye


    So if you enter user1 as the ID the database would look it up and see that the password must match hello or it will pop up an error. Just curious on how you would acomplish something like that. Thanks

  2. #2
    New Lounger
    Join Date
    Sep 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looking up from database and validating (VB6)

    Just one of many ways to do it...

    Use this (pseudo) SQL to query your table:
    SELECT UserID FROM table WHERE UserID = txtUserID.text AND Password = txtPassword.text

    After executing the SQL, check your recordset...if it's empty, present the error message, otherwise continue on your way.

  3. #3
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looking up from database and validating (VB6)

    What are some of the many other ways? It would be good to have a variety for this kind of thing because from my experience in programming, well sometimes things don't exactly work like they are supposed to.

  4. #4
    New Lounger
    Join Date
    Sep 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looking up from database and validating (VB6)

    Here's another - and probably better - one...

    SELECT UserID, Password FROM table WHERE UserID = txtUserID.text

    If rs.BOF Or rs.EOF then
    UserID does not exist
    ElseIf rs(

  5. #5
    2 Star Lounger
    Join Date
    May 2002
    Location
    USA
    Posts
    190
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Looking up from database and validating (VB6)

    hmm...yes that does seem a better way of handling it. Well thanks for the input of ideas. I was just curios as to what exactly was needed to be done to do it since I have never done something like that before. Course I'm new to VB as well so anything I learn is pretty new to me.

Posting Permissions

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