the following is the code for login using database... but this takes
only the first value (ID=1 in ms access)
can u plz help me??


Public Class LoginForm1

    Dim inc As Integer
    Dim MaxRows As Integer
    Dim con As New OleDb.OleDbConnection
    Dim ds As New DataSet
    Dim da As OleDb.OleDbDataAdapter
    Dim sql As String

    Private Property cmd As Object

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OK.Click
        con.ConnectionString = "PROVIDER=Microsoft.JET.OLEDB.4.0;Data
Source = D:\Userpassword.mdb"
        con.Open()
        Dim sql As String

        Dim dr As OleDb.OleDbDataReader
        sql = ("SELECT UserName,Password from userpass Where
[UserName]='" & Trim(UsernameTextBox.Text) & "'And [Password]='" &
Trim(PasswordTextBox.Text) & "'")
        cmd = New OleDb.OleDbCommand(sql, con)
        dr = cmd.Executereader()

        If (dr.HasRows) = False Then Exit Sub


        While (dr.read())
            If (UsernameTextBox.Text) = dr(0).ToString() And
(PasswordTextBox.Text) = dr(1).ToString() Then

                MsgBox("Thank You... You are logged in as " +
UsernameTextBox.Text)
            Else
                MsgBox("Please Enter your details correctly")
                UsernameTextBox.Text = ""
                PasswordTextBox.Text = ""
            End If
        End While

        dr.close()
        cmd = Nothing
        con.close()
    End Sub

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Cancel.Click
        Me.Close()
    End Sub

End Class

-- 
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net

Reply via email to