Hello,
Could any one plz tell, where am i going wrong. I am unable to popup msgbox if count=0. It will work only if i use
MsgBox(""). I am unable to understand how it has anything to do with msgbox("")
Private Sub txtstaffID_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtstaffID.TextChanged
Dim conn As SqlClient.SqlConnection
conn = New SqlClient.SqlConnection("Data Source= ***.**.**.**; Initial Catalog=abc; Persist Security Info=True; User ID=" & user & "; Password=" & password)
Dim da As SqlClient.SqlDataAdapter
Dim dt As New DataTable
If txtstaffID.Text.Contains("E?") Then
strParsedEMPL = txtstaffID.Text.Substring(5, 6)
txtstaffID.Text = "w" + strParsedEMPL
da = New SqlClient.SqlDataAdapter("select position FROM staff WHERE id = ('" + txtstaffID.Text + "')", conn)
MsgBox("")
da.Fill(dt)
If dt.Rows.Count = 1 Then
txtstaffID.ReadOnly = True
MsgBox("You are allowed to access ")
conn.Close()
cmdNext.Enabled = True
ElseIf dt.Rows.Count = 0 Then
txtstaffID.ReadOnly = False
MsgBox("ID not found ")
cmdNext.Enabled = False
ElseIf dt.Rows.Count > 1 Then
txtstaffID.ReadOnly = False
MsgBox(" more than 2 found")
End If
End If
End Sub
Both IF and Elseif code executes but the problem is the msgbox won't popup in both the cases( i.e when IF executes and when Elseif executes) unless and untill i have a msgbox("") before da.Fill(dt)