数据库里面有登陆表然后想对表进行更新操作,这是定义查询用户表的代码
 Public Sub linker()
        Dim conn As New SqlConnection
        Dim sql As String
        conn.ConnectionString = "data source=192.168.31.199;initial catalog=kaoqin manager;user id=james5;password=james5;"
        sql = "select dengluNO,alias,name,department,useableness from denglu"
        Dim cmd As New SqlCommand(sql, conn)
        conn.Open()
        Dim dr As New SqlDataAdapter(cmd)
        Dim dl As New DataSet
        dr.Fill(dl)
        GridView1.DataSource = dl.Tables(0).DefaultView
        GridView1.DataBind()
        conn.Close()
    End Sub
想在gridview对表进行更新操作,这是更新的代码;
  Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
        Dim txtnicheng, txtname, txtbumen, txtkeyong As TextBox
        'txtbianhao = Me.GridView1.Rows(e.RowIndex).Cells(0).Controls(0)
        txtnicheng = Me.GridView1.Rows(e.RowIndex).Cells(1).Controls(0)
        txtname = Me.GridView1.Rows(e.RowIndex).Cells(2).Controls(0)
        txtbumen = Me.GridView1.Rows(e.RowIndex).Cells(3).Controls(0)
        txtkeyong = Me.GridView1.Rows(e.RowIndex).Cells(4).Controls(0)
        Dim conn As New SqlConnection
        conn.ConnectionString = "data source=192.168.31.199;initial catalog=kaoqin manager;user id=james5;password=james5;"
        Dim sql As String
        sql = "update denglu set alias='" & txtnicheng.Text & "',department='" & txtbumen.Text & "',name='" & txtname.Text & "',useableness=" & txtkeyong.Text & " where dengluNO=" & Me.GridView1.DataKeys(e.RowIndex).Value.ToString
        Dim cmd As New SqlCommand(sql, conn)
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        Me.GridView1.EditIndex = -1
        Call linker()
    End Sub
一点更新就会出错,并且提示索引不能超出范围.请问这些代码哪儿有问题,为什么索引会超出范围,gridview第一列是编号(dengluNO)第二例是呢称(alias),第三列是姓名(name),第四列是所属部门(department),第五列是是否可用(useableness)接下来两列是编辑和删除,肯定大家帮忙