由于此错误,我无法运行我的程序。有人能帮助我吗?感谢。
公共课程登录
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
结束班
答案 0 :(得分:3)
您无法将else
置于while end-while
内,if-else-end if
和while-end while
是独立声明,因此您可以按以下方式混合使用:
while
if
else
end if
end while
或
if
while
end while
else
while
end while
end if
进入嵌套语句的唯一方法是GoTo
语句,它将指令指针无条件地移动到指定的标签。
答案 1 :(得分:0)
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
'尝试在while时或上方移动其他位置