Im trying to create a Log in system, Using VB.net 2010, im having a hard time creating a query for the username and password, and also how to make it case sensitive.

please help me,...thanks.

If user names are unique you can select them from the table.

If your user passwords are not encrypted, and are plain text (I HOPE AND PRAY that this is only a exercise!) Then you can just check the password field.

For example:

Private Function Autherized(ByVal sUser As String, ByVal sPass As String) As Boolean
    Try
        'Get your real connection string @ www.connectionstrings.com
        Dim da As New OleDbDataAdapter("SELECT * FROM tblUsers WHERE User='" & sUser & "'", New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccess2007file.accdb;Persist Security Info=False;"))
        Dim ds As New DataSet

        da.Fill(ds, "pw")

        If Not IsNothing(ds.Tables("pw")) And ds.Tables("pw").Rows.Count > 0 Then
            If ds.Tables("pw").Rows(0)("Password") = sPass Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    Catch ex As Exception
        MsgBox(ex.ToString)
        Return False
    End Try
End Function

Now just call the function when the user presses the login button:

Private Sub btnLogin_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnLogin.Click
    Try
        If Autherized(txtUser.text,txtPass.Text) Then 'Both are text boxes.
            'Do work for autherized users.
        Else
            MsgBox("You are not autherized to access this application!")
        End If       
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub

Edited 3 Years Ago by Begginnerdev

This article has been dead for over six months. Start a new discussion instead.