Foxtable(狐表)用户栏目专家坐堂 → 出现超出数组范围提示怎么回事?


  共有10073人关注过本帖树形打印复制链接

主题:出现超出数组范围提示怎么回事?

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


加好友 发短信
等级:童狐 帖子:294 积分:4701 威望:0 精华:0 注册:2011/5/28 8:21:00
出现超出数组范围提示怎么回事?  发帖心情 Post By:2012/2/6 14:48:00 [只看该作者]

出现超出数组范围提示怎么回事?

 回到顶部
帅哥哟,离线,有人找我吗?
zcw2764
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:294 积分:4701 威望:0 精华:0 注册:2011/5/28 8:21:00
  发帖心情 Post By:2012/2/6 14:52:00 [只看该作者]

Dim Name As String = e.Form.Controls("Name").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
If Name = "" Then
    Messagebox.show("请选择或输入用户登录名!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
End If
cmd.CommandText = "Select * From {用户} Where [登录名] = '" & Name & "'"
dt = cmd.ExecuteReader
dr = dt.DataRows(0)
If dt.DataRows.Count = 0 Then '返回1表示更改成功
    Messagebox.show("用户名输入错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    Return
Else
    If  dr("禁用") = True Then
        Messagebox.show("此用户已禁用,请与管理员联系!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Return
    Else
        If e.Form.Controls("PassWord").Value = dr("密码") Then
            _Name = Name
            _UserName = dr("用户名")
            _UserGroup = dr("用户组")
            _UserJS = dr("角色")
            e.Form.Close
        Else
            Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    End If

登录时输入的用户名不在用户表中,确定时出现“超出数组范围”的错误提示


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251048 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/2/6 14:58:00 [只看该作者]

cmd.CommandText = "Select * From {用户} Where [登录名] = '" & Name & "'"
dt = cmd.ExecuteReader
dr = dt.DataRows(0)

改为:

 

 

cmd.CommandText = "Select * From {用户} Where [登录名] = '" & Name & "'"
dt = cmd.ExecuteReader
if  dt.Datarows.Count = 0 then

    Messagebox.show("用户名错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)

    return

End if

dr = dt.DataRows(0)


 回到顶部
帅哥哟,离线,有人找我吗?
zcw2764
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:294 积分:4701 威望:0 精华:0 注册:2011/5/28 8:21:00
  发帖心情 Post By:2012/2/6 15:09:00 [只看该作者]

已解决,谢谢

 回到顶部