Results 1 to 4 of 4

Thread: Login System in Visual Studio 2010

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2015
    Posts
    34

    Login System in Visual Studio 2010

    Hello ! I am making a login system in visual studio 2010 . I used this code and it works fine !
    Code:
       My.Settings.Username = TextBox1.Text
                My.Settings.Password = TextBox2.Text
    
                My.Settings.Save()
                MsgBox("Account Created !", MsgBoxStyle.Information, "Create")
    The only problem is that when it only remembers my username and password untill I close my project's .exe file . After I close it and reopen it all the saved data gets deleted . Could you help me by telling that how can I build a login system in which the data should not get lost even after I close the .exe file ? Many thanks !

  2. #2
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: Login System in Visual Studio 2010

    You can't using that method, as each time you enter a new user and password it will write over the last one.

    The settings file is a terrible place to hold username / password information, as it completely insecure.

    If you want to have multiple users of your system then you will need to use a database here is decent example of how you might go about it.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  3. #3
    Lively Member
    Join Date
    Aug 2011
    Posts
    66

    Re: Login System in Visual Studio 2010

    Quote Originally Posted by NeedSomeAnswers View Post
    You can't using that method, as each time you enter a new user and password it will write over the last one.

    The settings file is a terrible place to hold username / password information, as it completely insecure.

    If you want to have multiple users of your system then you will need to use a database here is decent example of how you might go about it.
    Hi. Thats a nice guide, but I cannot find and understand where is the code that actually checks if the password and username is wrong or correct.

  4. #4
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: Login System in Visual Studio 2010

    That's in Section 9, (the second black back-grounded code block).

    This is the code he uses - >

    Dim sql As String = "SELECT * FROM tbl_user WHERE username='" & txtUsername.Text & "' AND password = '" & txtPassword.Text & "'"
    Dim sqlCom As New System.Data.OleDb.OleDbCommand(sql)

    'Open Database Connection
    sqlCom.Connection = conn
    conn.Open()
    Dim sqlRead As System.Data.OleDb.OleDbDataReader = sqlCom.ExecuteReader()
    So basically he doesn't compare username and password exactly as checks to see if any users exist in the database with that Username & Password. If non exist then the user doesn't exist !

    There are a number of issues with his code now i look at it closer specifically he doesn't use Parameters, but if you follow it all the way through then it should give you a good idea about how to get started, and i (and plenty of others here) can show you how to use parameters.

    If you try and create your own Login system i will be more then happy to help with your code. Just post what you are trying out and i will see how i can help.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



Tags for this Thread

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