Reputation: 3
I cant run my program due to this error. Can somebody help me? Thanks.
Public Class Login
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
Dim SM As New SubjectMaintenance
Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)
While dr.Read
GUI.accnt.pData_id = dr(Account.si_data_id)
Me.Hide()
GUI.Show()
**Else**
GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
GUI.accnt.pData_username = dr(Account.si_data_username)
GUI.accnt.pData_lname = dr(Account.si_data_lname)
GUI.accnt.pData_fname = dr(Account.si_data_fname)
GUI.accnt.pData_mname = dr(Account.si_data_mname)
End While
SM.closeConDr()
If GUI.accnt.pData_id > 0 Then
MessageBox.Show("Login Failed!")
End If
End If
End Sub
End Class
Upvotes: 0
Views: 789
Reputation: 9
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If tbx_username.Text <> "" And tbx_pass.Text <> "" Then
Dim SM As New SubjectMaintenance
Dim dr = SM.openSel(SqlString.getSQLSelect(Account.tablename, Account.si_data_username & "='" & tbx_username.Text & "' and " & Account.si_data_pwd & "='" & tbx_pass.Text & "'"), CommandType.Text)
While dr.Read
GUI.accnt.pData_id = dr(Account.si_data_id)
Me.Hide()
GUI.Show()
End While
**Else** 'Try moving the else below the end while or above the while
GUI.accnt.pData_pwd = dr(Account.si_data_pwd)
GUI.accnt.pData_username = dr(Account.si_data_username)
GUI.accnt.pData_lname = dr(Account.si_data_lname)
GUI.accnt.pData_fname = dr(Account.si_data_fname)
GUI.accnt.pData_mname = dr(Account.si_data_mname)
SM.closeConDr()
If GUI.accnt.pData_id > 0 Then
MessageBox.Show("Login Failed!")
End If
End If
End Sub
'Try moving the else below the end while or above the while
Upvotes: 0
Reputation: 14860
You cannot put an else
inside while end-while
, the if-else-end if
and while-end while
are standalone statements, so you can mix them as follows:
while
if
else
end if
end while
or
if
while
end while
else
while
end while
end if
The only way to break into a nested statement is the GoTo
statement, it moves the instruction pointer unconditionally to the specified label.
Upvotes: 3