Foxtable(狐表)用户栏目专家坐堂 → 自定义用户的登录判断


  共有7867人关注过本帖平板打印复制链接

主题:自定义用户的登录判断

帅哥哟,离线,有人找我吗?
jaegea
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:480 积分:3832 威望:0 精华:0 注册:2011/5/31 15:45:00
自定义用户的登录判断  发帖心情 Post By:2012/4/21 17:46:00 [只看该作者]

自定义用户管理中,在用户登录的“确定”按钮中,怎样在登录之前进行对输入的用户名的判断,如无此用户名返回一个信息提示,以下代码只能是判断空值,如果输入的不是空值,但用户表中无此用户名的话就会出现程序错误。说明一下,输入框必须支持手工输入的。

 

Dim UserName As String = e.Form.Controls("UserName").Value
Dim
cmd As New SQLCommand
Dim
dt As DataTable
Dim
dr As DataRow
cmd.ConnectionName =
"User"
If
UserName = "" Then
    Messagebox.show(
"请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End
If
cmd.CommandText =
"Select * From {Users} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
dr = dt.DataRows(
0)
If
e.Form.Controls("PassWord").Value = dr("Password") Then
    _UserName = UserName
    _UserGroup = dr(
"Group")
    e.Form.Close

Else

    Messagebox.show(
"密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If


 回到顶部