所以我们有一个登录表单,程序必须检测用户分配的位置。 (选择位置是在注册期间完成的,因此用户的位置已经保存到数据库中)。据说,每个职位都有一个单独的表格。
Dim username As String = txtUser.Text
Dim password As String = txtPass.Text
//check if username and password exist
checklogin(username, password)
If RS.EOF Then
MessageBox.Show("Mismatch Entry", "confirmation Message", MessageBoxButtons.OKCancel, MessageBoxIcon.Error)
txtUser.Clear()
txtUser.Focus()
Else
Me.Hide()
//problem starts here
checkposition()
If (position == "Officer")
OfficerForm.Show()
Elseif (position == "Head")
HeadForm.Show()
Elseif (position == "Admin")
AdminForm.Show()
Else
// dialog box
End If
End Sub
核对位置的方法:
Public Sub checkpositon(ByVal username As String, ByVal positon As String)
RS = CN.Execute("SELECT position FROM admin WHERE uName = '" & username & "' ")
End Sub
我知道代码中仍然缺少某些内容。我知道它有什么问题。 如何将数据库中的位置检索到登录表单中?请帮忙 :( 谢谢!
答案 0 :(得分:0)
函数checkposition()的第二个参数应该命名为'position'而不是'positon'。此外,您需要为位置指定一个值,例如
position = RS.Fields.Item(0);
你应该逃避用户名的价值