LobsterSte
Programmer
I am stuck on a problem where I have a select statment, but the datareader can't get the string If there is no record in the table with the same intCID.
Here IS My Code:
Private Sub testPin(ByVal UserID As Integer, ByVal Password As String)
Try
Dim cmd As New SqlCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT dbo.tblCustomers.intPIN, dbo.tblCustomers.strFName, dbo.tblCustomers.strLName, dbo.tblRent.strProcess FROM dbo.tblCustomers INNER JOIN dbo.tblRent ON dbo.tblCustomers.intCID = dbo.tblRent.intCID Where dbo.tblCustomers.intCID =" & UserID & ""
cnn.Open()
cmd.Connection = cnn
Dim dr As SqlDataReader = cmd.ExecuteReader
Try
While dr.Read
If dr.GetInt32(0) = Password Then
txtFName.Text = dr.GetString(1)
txtLName.Text = dr.GetString(2)
Try
If dr.GetString(3) = "Complete" Then
UserClear = True
Else
UserClear = False
End If
Catch ex As Exception
MsgBox("ASS")
End Try
Else
ErrorProvider1.SetError(txtCustPin, "Customer Pin Wrong!")
End If
End While
dr.Close()
cnn.Close()
Catch ex As Exception
MsgBox("User Pin: " & ex.Message)
Finally
If UserClear = False Then
MsgBox("Customer Still Has Items!", MsgBoxStyle.Exclamation, "Customer")
btnFindDVD.Enabled = False
ClearForm()
Else
btnFindDVD.Enabled = True
MsgBox("Customer Credentials Checked Sucessfull", MsgBoxStyle.Information, "Customer Credentials")
End If
End Try
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any Ideas?
Here IS My Code:
Private Sub testPin(ByVal UserID As Integer, ByVal Password As String)
Try
Dim cmd As New SqlCommand
cmd.CommandType = CommandType.Text
cmd.CommandText = "SELECT dbo.tblCustomers.intPIN, dbo.tblCustomers.strFName, dbo.tblCustomers.strLName, dbo.tblRent.strProcess FROM dbo.tblCustomers INNER JOIN dbo.tblRent ON dbo.tblCustomers.intCID = dbo.tblRent.intCID Where dbo.tblCustomers.intCID =" & UserID & ""
cnn.Open()
cmd.Connection = cnn
Dim dr As SqlDataReader = cmd.ExecuteReader
Try
While dr.Read
If dr.GetInt32(0) = Password Then
txtFName.Text = dr.GetString(1)
txtLName.Text = dr.GetString(2)
Try
If dr.GetString(3) = "Complete" Then
UserClear = True
Else
UserClear = False
End If
Catch ex As Exception
MsgBox("ASS")
End Try
Else
ErrorProvider1.SetError(txtCustPin, "Customer Pin Wrong!")
End If
End While
dr.Close()
cnn.Close()
Catch ex As Exception
MsgBox("User Pin: " & ex.Message)
Finally
If UserClear = False Then
MsgBox("Customer Still Has Items!", MsgBoxStyle.Exclamation, "Customer")
btnFindDVD.Enabled = False
ClearForm()
Else
btnFindDVD.Enabled = True
MsgBox("Customer Credentials Checked Sucessfull", MsgBoxStyle.Information, "Customer Credentials")
End If
End Try
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any Ideas?