Results 1 to 12 of 12

Thread: Login dialog + Access db

  1. #1

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Smile Login dialog + Access db

    Hello!

    I have one MDI app and I need to make login dialog...
    If user is not in Access db as "user" then he cant login (open app)...

    For me it is ok default studio logindialog form...
    I need help how to connect username and pww textboxes with access db to check is this user in db or not...

    If yes then open app, if not then msgbox...



    Ivo

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Login dialog + Access db

    Follow the CodeBank link in my signature and check out my WinForms Login thread.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Re: Login dialog + Access db

    ^^
    thanks so much, this really helped me...

    but I have small issue in my code...

    Here I get error "Too many arguments to "Public ReadOnly Default Property Chars(index As Integer) As Char"
    On Return ... Me.PasswordTextBox.Text
    Code:
    Private Function ValidateCredentialsByTableAdapter() As Boolean
            Using adapter As New dbloginDataSetTableAdapters.useriTableAdapter
                Return adapter.userQuery(Me.UsernameTextBox.Text.Trim(), Me.PasswordTextBox.Text).Value > 0
            End Using
        End Function

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Login dialog + Access db

    What's the signature of your 'userQuery' method?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Re: Login dialog + Access db

    Thanks, I have find my problem...

    This is in yours example
    Code:
    Public Overridable Overloads Function GetUserCountByUserNameAndPassword(ByVal UserName As String, ByVal Password As String) As Global.System.Nullable(Of Integer)

    And this was in my
    Code:
    Public Overloads Overridable Function userQuery() As String

  6. #6

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Re: Login dialog + Access db

    Hm...

    Again some mistake...
    When I run APP Cancel button works great but OK button doesn't...
    If I press OK with empty or filed text boxes this is what I get...


  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Login dialog + Access db

    First things first, you should turn Option Strict On for this and all other projects. That error would have been picked up at compile time instead of slipping through to run time. I think the error message should speak for itself. You're passing a String where an Integer is expected. If you're validating credentials then obviously you want to pass text and not numbers, so you have designed your query incorrectly.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Re: Login dialog + Access db

    Thanks!
    You are correct, it was query...

    Now it works but now when I insert username and password nothing happens, form doesn't open and I cant find my problem

  9. #9

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Re: Login dialog + Access db

    Of course, I did this with Me.Hide and Form.Show but Im interested how did you do it because I cant find it

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Login dialog + Access db

    I've already provided you with specific instructions on how to do it. If you follow those instructions then it will work. If it doesn't work then you didn't follow the instructions. I can't possibly say what you have done wrong because I haven't seen what you've done.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  11. #11

    Thread Starter
    Addicted Member _ivo_'s Avatar
    Join Date
    Sep 2009
    Location
    Zagreb
    Posts
    140

    Re: Login dialog + Access db

    I made some small changes and it works now so thanks very much for this


    I have one more question, maybe you can help me...
    I have setup project for one project and when I build this project Access database is empty...
    This means I dont have any username and password to login with...
    Is there some option not to delete data from Access when building setup project?

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Login dialog + Access db

    Building a Setup project doesn't delete any data. When you build your project, the source database is copied from the source folder to the output folder. This applies to Debug and Release builds. Any changes you make while debugging are only made to the copy in the Debug folder. If you want standard data in the database all the time then it must be in the source database, so it will then also be in every copy.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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