bprego Level: Guest

|
trying to create a login form
here is what i am working with right now:
varUser_Name, varPassword, varOperatorID are public variables
declares in a module. my query is not returning the operatorID.
thanks in advance for any help.
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnLogin.Click
LoginSuccess = False
ValidateLogin()
If LoginSuccess = True Then
Dim formToOpen As frmAdmin
formToOpen = New frmAdmin
formToOpen.Show()
Me.Hide()
End If
End Sub
Public Sub ValidateLogin()
Dim oConn As SqlConnection = New SqlConnection
Dim oTable As DataTable = New DataTable
varUser_Name = txtUserName.Text
varPassword = txtPassword.Text
Try
oConn.ConnectionString = "my connection"
oConn.Open()
Dim oDA As SqlDataAdapter = New SqlDataAdapter("select
operator_ID from operator where (username ='" & varUser_Name & "'
and password = '" & varPassword & "'", oConn)
oDA.Fill(oTable)
oConn.Close()
Dim oRow As DataRow
For Each oRow In oTable.Rows
varOperatorID = CStr(oRow("OPERATOR_ID"))
Next
Catch e As Exception
If varOperatorID = 0 Then
LoginSuccess = False
MsgBox("Incorrect Login.",
MsgBoxStyle.OKOnly, "Login Error")
txtUserName.Text = ""
txtPassword.Text = ""
txtUserName.Focus()
Else
LoginSuccess = True
End If
Finally
If oConn.State = ConnectionState.Open Then
oConn.Close()
End If
End Try
End Sub
|