Rss & SiteMap
Foxtable(狐表) http://www.foxtable.com
如果输入的账号不存在就弹窗提示“账号不存在”,请问代码应该怎么写啊?
请帮忙在我一下代码中添加,谢谢!
Dim UserName As String = e.Form.Controls("账号1").Value
Dim Usermima As String = e.Form.Controls("密码1").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
If UserName = "" Then
Messagebox.show("请输入用户名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {xtuser} Where [用户账号] = '" & UserName & "'"
dt = cmd.ExecuteReader
dr = dt.DataRows(0)
If Usermima = dr("用户密码") Then
e.Form.Close
Else
Messagebox.show("用户账号或密码不正确!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
输入该代码后,按确定就提示count 不是DataTable的成员
帮忙看看以下代码出错在哪里!黄色字体的代码运行时提示“count 不是DataTable的成员”,粉红色字体的代码运行时提示“登录状态”不属于“表”,我是想账号密码正确就保存“登陆状态”为“TRUE”
Dim UserName As String = e.Form.Controls("账号1").Value
Dim Usermima As String = e.Form.Controls("密码1").Value
Dim rdo1 As WinForm.RadioButton
Dim rdo2 As WinForm.RadioButton
rdo1 = e.Form.Controls("收银台")
rdo2 = e.Form.Controls("管理台")
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
If UserName = "" Then
Messagebox.show("请输入用户名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
ElseIf Usermima = "" Then
Messagebox.show("请输入登陆密码!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
ElseIf Usermima.Length <> 6 Then
Messagebox.show("密码长度不足6位数!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {xtuser} Where [用户账号] = '" & UserName & "'"
dt = cmd.ExecuteReader
If dt.count=0 Then
Messagebox.show("账号不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
dr = dt.DataRows(0)
Dim dr1 As DataRow
If Usermima = dr("用户密码") Then
If dr("登录状态") = False Then
If rdo1.Checked = True Then
dr1("登录状态") = True
e.Form.Close()
ElseIf rdo2.Checked = True Then
MessageBox.Show("后台尚在制作中……暂时不能使用!", "温馨提示!")
End If
Else
MessageBox.Show("该账号已经在其他终端登陆!", "温馨提示!")
End If
Else
Messagebox.show("用户账号或密码不正确!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
Dim cmd As New SQLCommand
cmd.CommandText = "Select Count(用户账号) From {xtuser} Where [用户账号] = '" & UserName & "'"
If cmd.ExecuteScalar() = 0 Then
Messagebox.show("账号不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
另外我觉得用UserName似乎不妥,应该用User.Name,我猜的。
Dim cmd As New SQLCommand
cmd.CommandText = "Select Count(用户账号) From {xtuser} Where [用户账号] = '" & UserName & "'"
If cmd.ExecuteScalar() = 0 Then
Messagebox.show("账号不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
另外我觉得用UserName似乎不妥,应该用User.Name,我猜的。
账号不存在提示问题已经解决,谢谢!
第二个问题:粉红色字体的代码运行时提示“登录状态”不属于“表”,我是想账号密码正确就保存“登陆状态”为“TRUE”
请问如何将TRUE保存到“登录状态”列中呢?