Need help fixing my Login Code in Visual Basic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pkminer30
    New Member
    • Nov 2011
    • 1

    #1

    Need help fixing my Login Code in Visual Basic

    My visual basic code is:

    Code:
    Public Class Form1
    
        Dim PasswordTrials As Integer
    
        Private Property TextPassword As Object
    
        Private Property TextUsername As Object
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim Login = Me.ClientsTableAdapter1.ClientQuery(TextUsername.Text, TextPassword.Text)
    
            If Login Is Nothing Then
                MsgBox("Please Enter Your Login Details", MsgBoxStyle.Critical)
                TextUsername.Value = ""
                TextPassword.Value = ""
                PasswordTrials = PasswordTrials + 1
                If PasswordTrials >= 3 Then
                    MsgBox("Login Attempts Exceeded, Spreadsheet Shutting Down", MsgBoxStyle.Critical)
                    End
                End If
            Else
                MsgBox("Login Successful, You Can Now Access The Spreadsheet", MsgBoxStyle.Information)
                End
            End If
        End Sub
    End Class
    I am having "NullReferanceE xception was Unhandled" at this line "Dim Login = Me.ClientsTable Adapter1.Client Query(TextUsern ame.Text, TextPassword.Te xt)"
Working...