I know this might have came up, but i have a login code and once logged in it would show u your information that u entered in the sql database just for that one person that logged in. Here is my problem when i login it shows another users information, please help i would really apperciate it.

here is the wrong code :P

Module Module1
Dim connection As New SqlClient.SqlConnection
Dim command As New SqlClient.SqlCommand
' Login and connecting to the database.
Public Sub Connect()
    Dim adapter As New SqlClient.SqlDataAdapter
    Dim dataset As New DataSet

    connection.ConnectionString = ("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\database.mdf;Integrated Security=True;User Instance=True")
    command.CommandText = "SELECT * FROM [pilots] WHERE pilotid =  '" & LoginForm.TextBox1.Text & "' AND password = '" & LoginForm.MaskedTextBox1.Text & "';"

    command.Connection = connection

    adapter.SelectCommand = command
    adapter.Fill(dataset, "0")
    Dim count = dataset.Tables(0).Rows.Count

    If count > 0 Then
        MsgBox("Wrong Login!")
    End If
End Sub

' here u would get the users information
Public Sub GetInfo()
        command.Connection = connection
        command.CommandText = "SELECT * FROM [table]"
        Dim lrd As SqlClient.SqlDataReader = command.ExecuteReader()

        While lrd.Read()
            PilotArea.Label8.Text = "First Name: " + lrd(0).ToString()
            PilotArea.Label9.Text = "Last Name: " + lrd(1).ToString()
        End While

    Catch ex As Exception
        MessageBox.Show("Error has occured on recieving credentials!" & ex.Message, "Loading Credentails!")
    End Try
End Sub

' this just closes the connection
Public Sub DestroySession()
End Sub

End Module

THANKS!!!! :)!!!!!!!!!

i am still confused on that can u show another link or explain without the asp.net, please.


i am not dealing with asp, i am just going with the program, and the problem is when i go to the user area, it would show another "First Name" in that field then the one i logged in with

Looks like the GetInfo sub doesn't have a "WHERE pilotid ="

command.CommandText = "SELECT * FROM [table]"  ' add where clause here

Hope that helps


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