Results 1 to 5 of 5

Thread: Security Login

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    2

    Smile Security Login

    I am relatively new to programming and could use some direction from someone more experienced.

    What I am trying to do is create a login routine for a VB.Net app I have created. I need to promp the user to enter a username and password, then compare their password with the password field in a SQL Server database for their userid. If they match, then go ahead and open the first form in the app.

    Basically I need someone to show me the syntax I should follow to connect to the database, formulate and run a select statement based on the userid they enter in the textbox, then compare the password they entered in a textbox to the one in the database. I'd like to use ADO.NET, but if there are other ways to do this, please feel free to respond. Thanks in advance!

  2. #2
    Lively Member Neoharuo's Avatar
    Join Date
    Aug 2005
    Posts
    100

    Re: Security Login

    Welcome to the forums!

    First you need to get the connection string.

    http://www.connectionstrings.com/

    This site has lots of them. Then you need to create a data adater and a data table and then just fill the table from the adapter. I'll post code if you need it.
    "I aim to misbehave."
    Captain Mal Reynolds

  3. #3
    Lively Member Neoharuo's Avatar
    Join Date
    Aug 2005
    Posts
    100

    Re: Security Login

    VB Code:
    1. Dim oConn As New SqlConnection = "Connection String Goes Here"
    2. Dim oAdpt As New SqlDataAdapter("Select * From Employee", oConn)
    3. Dim oDTbl As New DataTable
    4.  
    5. oADpt.Fill(oDTble)
    6.  
    7. Dim oTempRow As DataRow
    8. For Each oTempRow In oDTbl.Rows
    9.      If oTempRow.Item("EmployeeID") = txtEmpID.Text Then
    10.           If oTempRow.Item("Password") = txtPassword.Text Then
    11.                'User Logs In
    12.           Else
    13.                'User Doesn't Log In
    14.           End If
    15.      End If
    16. Next
    Last edited by Neoharuo; Sep 13th, 2005 at 11:40 AM.
    "I aim to misbehave."
    Captain Mal Reynolds

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    2

    Re: Security Login

    That is exactly what I needed. It worked perfectly. Thanks Neoharuo!

  5. #5
    Lively Member Neoharuo's Avatar
    Join Date
    Aug 2005
    Posts
    100

    Re: Security Login

    Quote Originally Posted by aarondba
    That is exactly what I needed. It worked perfectly. Thanks Neoharuo!
    NP glad to be of help!
    "I aim to misbehave."
    Captain Mal Reynolds

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