• Looking up from database and validating (VB6)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Looking up from database and validating (VB6)

    Author
    Topic
    #358618

    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

    Viewing 0 reply threads
    Author
    Replies
    • #535523

      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.

      • #535822

        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.

        • #535839

          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(

          • #535855

            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.

    Viewing 0 reply threads
    Reply To: Looking up from database and validating (VB6)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: