How Can I fix this Login Form to Return The ID of the person that logs in

时间:2017-06-04 23:37:13

标签: sql vb.net winforms dataset

I am getting System.NullReferenceException: 'Object reference not set to an instance of an object.' At the Dim r.

I am trying to pass username and password as paramerters to my tableadapter I need it to return the ID that it checks and approves

Private Sub btnLogin_Click(sender As Object, e As EventArgs) Handles btnLogin.Click


    Dim r = Me.ApsApplication_usersTableAdapter1.SelectUsername(Nothing, Me.TxTUser.Text, Me.TxTPass.Text)
    If r = Nothing Then
        MessageBox.Show("Invalid Username")
    Else
        LoginSucess()
        GlobalVariables.UserID = r ' store userid in current session
        GlobalVariables.LoggedIn = True
    End If


End Sub

This is my code for my Table Adapter

SELECT        ID AS UserID, username AS UserNameInput, password AS PasswordInput
FROM            APSApplication_users
GROUP BY ID, username, password
HAVING        (username = @Param1) AND (password = @Param2)

How do I fix this?

0 个答案:

没有答案