It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

UserID not retained after login?

Moderator: dafunkymunky

UserID not retained after login?

Postby ospreyuk on Thu Apr 08, 2010 2:02 pm

I am trying to write a program where a user logs on to the system and then enters predictions for the world cup matches. I have created the login screen which searches the 'users' database for the inputted username and password - it works (kind of) in the fact that users are granted or denied access. After a successful login, however, the system seems to forget who's logged in, therefore any predictions entered cannot be related the the userID of the 'users' table. I am frustrated to say the least. Here's the code I have in the 'login' button of the login screen:
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connection As New SqlClient.SqlConnection
        Dim command As New SqlClient.SqlCommand
        Dim adaptor As New SqlClient.SqlDataAdapter
        Dim dataset As New DataSet

        connection.ConnectionString = ("Data Source=FEF-IT-002\SQLEXPRESS;Initial Catalog=WCPS;Integrated Security=True")
        command.CommandText = "SELECT * FROM  [Users] WHERE Username= '" & TextBox1.Text & "'AND Password= '" & TextBox2.Text & "';"
        connection.Open()
        command.Connection = connection
        Dim sdr As SqlClient.SqlDataReader = command.ExecuteReader()
        ' If the record can be queried, Pass verification and open another form.   
        If (sdr.Read() = True) Then
            MDIParent1.Show()
        Else
            MsgBox("Incorrect username or password", MsgBoxStyle.Critical)
            TextBox1.Clear()
            TextBox2.Clear()
            Me.Refresh()
        End If
    End Sub

Can anybody out help me?
ospreyuk
 
Posts: 1
Joined: Thu Apr 08, 2010 1:44 pm

Who is online

Users browsing this forum: No registered users and 4 guests