Hi All,

I have a login form connecting to a SQL Database but when the OnClick event fires, nothing occurs. I now that it is sorta working because if the user name / password fields are left blank, an error message is displayed

Code:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        If UsernameTextBox.TextLength > 1 And UsernameTextBox.TextLength > 1 Then


            Try

                Dim connStr As String = ConfigurationManager.ConnectionStrings("CRM.NET.My.MySettings.CRMConnectionString").ConnectionString
                Dim SQL As String = "SELECT UserID, Password FROM tblUsers WHERE UserID = '" & UsernameTextBox.Text & "' AND Password = '" & PasswordTextBox.Text & "'"

                Dim myCommand As New SqlCommand(SQL, New SqlConnection(connStr))

                myCommand.Connection.Open()

                Dim dr As SqlDataReader

                dr = myCommand.ExecuteReader()

                If Not dr.Read() Then

                    MessageBox.Show("Login Failed")

                Else

                    Dim Form1 As New Form1
                    Form1.Show()

                End If

            Catch ex As Exception

            End Try

        Else

            MessageBox.Show("Username and Password Must Be Entered")

        End If

    End Sub