Imports MySql.Data.MySqlClient
Imports System.Data
Partial Class UserInfo
Inherits System.Web.UI.Page
Private Sub BindData()
Using con As MySqlConnection = New MySqlConnection(Dao.cs)
Using cmd As MySqlCommand = New MySqlCommand("select * from userinfo", con)
Using da As MySqlDataAdapter = New MySqlDataAdapter(cmd)
Using ds As DataSet = New DataSet()
da.Fill(ds)
Me.GridView1.DataSource = ds
Me.GridView1.DataBind()
End Using
End Using
End Using
End Using
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.BindData()
End If
End Sub
Protected Sub GridView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles GridView1.PageIndexChanging
Me.GridView1.PageIndex = e.NewPageIndex
Me.BindData()
End Sub
Protected Sub GridView1_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GridView1.RowCancelingEdit
Me.GridView1.EditIndex = -1
Me.BindData()
End Sub
Protected Sub GridView1_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
Dim l_username As Label = Me.GridView1.Rows(e.RowIndex).FindControl("l_username")
Dim l_userpass As Label = Me.GridView1.Rows(e.RowIndex).FindControl("l_userpass")
Dim cb_a As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_a")
Dim cb_b As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_b")
Dim cb_c As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_c")
Dim cb_d As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_d")
Dim cb_e As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_e")
Dim cb_f As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_f")
Dim cb_g As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_g")
Dim cb_h As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_h")
Dim cb_i As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_i")
Dim cb_j As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_j")
Dim cb_k As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_k")
Dim cb_l As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_l")
Dim cb_m As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_m")
Dim cb_n As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_n")
Dim cb_o As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_o")
Dim cb_p As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_p")
Dim cb_q As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_q")
Dim cb_r As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_r")
Dim cb_s As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_s")
Dim cb_t As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_t")
Dim cb_u As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_u")
Dim cb_v As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_v")
Dim cb_w As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_w")
Dim cb_x As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_x")
Dim cb_y As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_y")
Dim cb_z As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_z")
Using con As MySqlConnection = New MySqlConnection(Dao.cs)
Using cmd As MySqlCommand = New MySqlCommand("delete from userinfo where username = ?username and userpass = ?userpass and a = ?a and b = ?b and c = ?c and d = ?d and e = ?e and f = ?f and g = ?g and h = ?h and i = ?i and j = ?j and k = ?k and l = ?l and m = ?m and n = ?n and o = ?o and p = ?p and q = ?q and r = ?r and s = ?s and t = ?t and u = ?u and v = ?v and w = ?w and x = ?x and y = ?y and z = ?z", con)
cmd.Parameters.AddWithValue("username", l_username.Text)
cmd.Parameters.AddWithValue("userpass", l_userpass.Text)
cmd.Parameters.AddWithValue("a", cb_a.Checked)
cmd.Parameters.AddWithValue("b", cb_b.Checked)
cmd.Parameters.AddWithValue("c", cb_c.Checked)
cmd.Parameters.AddWithValue("d", cb_d.Checked)
cmd.Parameters.AddWithValue("e", cb_e.Checked)
cmd.Parameters.AddWithValue("f", cb_f.Checked)
cmd.Parameters.AddWithValue("g", cb_g.Checked)
cmd.Parameters.AddWithValue("h", cb_h.Checked)
cmd.Parameters.AddWithValue("i", cb_i.Checked)
cmd.Parameters.AddWithValue("j", cb_j.Checked)
cmd.Parameters.AddWithValue("k", cb_k.Checked)
cmd.Parameters.AddWithValue("l", cb_l.Checked)
cmd.Parameters.AddWithValue("m", cb_m.Checked)
cmd.Parameters.AddWithValue("n", cb_n.Checked)
cmd.Parameters.AddWithValue("o", cb_o.Checked)
cmd.Parameters.AddWithValue("p", cb_p.Checked)
cmd.Parameters.AddWithValue("q", cb_q.Checked)
cmd.Parameters.AddWithValue("r", cb_r.Checked)
cmd.Parameters.AddWithValue("s", cb_s.Checked)
cmd.Parameters.AddWithValue("t", cb_t.Checked)
cmd.Parameters.AddWithValue("u", cb_u.Checked)
cmd.Parameters.AddWithValue("v", cb_v.Checked)
cmd.Parameters.AddWithValue("w", cb_w.Checked)
cmd.Parameters.AddWithValue("x", cb_x.Checked)
cmd.Parameters.AddWithValue("y", cb_y.Checked)
cmd.Parameters.AddWithValue("z", cb_z.Checked)
Try
con.Open()
Dim i As Integer = cmd.ExecuteNonQuery()
If i > 0 Then
Response.Write("删除成功")
Else
Response.Write("删除失败")
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Using
End Using
Me.BindData()
End Sub
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
Me.GridView1.EditIndex = e.NewEditIndex
Me.BindData()
End Sub
Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim tb_username As TextBox = Me.GridView1.Rows(e.RowIndex).FindControl("tb_username")
Dim tb_userpass As TextBox = Me.GridView1.Rows(e.RowIndex).FindControl("tb_userpass")
Dim cb_a As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_a")
Dim cb_b As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_b")
Dim cb_c As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_c")
Dim cb_d As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_d")
Dim cb_e As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_e")
Dim cb_f As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_f")
Dim cb_g As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_g")
Dim cb_h As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_h")
Dim cb_i As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_i")
Dim cb_j As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_j")
Dim cb_k As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_k")
Dim cb_l As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_l")
Dim cb_m As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_m")
Dim cb_n As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_n")
Dim cb_o As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_o")
Dim cb_p As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_p")
Dim cb_q As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_q")
Dim cb_r As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_r")
Dim cb_s As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_s")
Dim cb_t As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_t")
Dim cb_u As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_u")
Dim cb_v As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_v")
Dim cb_w As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_w")
Dim cb_x As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_x")
Dim cb_y As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_y")
Dim cb_z As CheckBox = Me.GridView1.Rows(e.RowIndex).FindControl("cb_z")
Dim hf_username As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_username")
Dim hf_userpass As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_userpass")
Dim hf_a As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_a")
Dim hf_b As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_g")
Dim hf_c As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_c")
Dim hf_d As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_d")
Dim hf_e As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_e")
Dim hf_f As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_f")
Dim hf_g As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_g")
Dim hf_h As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_h")
Dim hf_i As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_i")
Dim hf_j As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_j")
Dim hf_k As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_k")
Dim hf_l As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_l")
Dim hf_m As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_m")
Dim hf_n As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_n")
Dim hf_o As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_o")
Dim hf_p As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_p")
Dim hf_q As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_q")
Dim hf_r As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_r")
Dim hf_s As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_s")
Dim hf_t As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_t")
Dim hf_u As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_u")
Dim hf_v As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_v")
Dim hf_w As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_w")
Dim hf_x As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_x")
Dim hf_y As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_y")
Dim hf_z As HiddenField = Me.GridView1.Rows(e.RowIndex).FindControl("hf_z")
Using con As MySqlConnection = New MySqlConnection(Dao.cs)
Using cmd As MySqlCommand = New MySqlCommand("update userinfo set username = ?username, userpass = ?userpass, a = ?a, b = ?b, c = ?c, d = ?d, e = ?e, f = ?f, g = ?g, h = ?h, i = ?i, j = ?j, k = ?k, l = ?l, m = ?m, n = ?n, o = ?o, p = ?p, q = ?q, r = ?r, s = ?s, t = ?t, u = ?u, v = ?v, w = ?w, x = ?x, y = ?y, z = ?z where username = ?Original_username and userpass = ?Original_userpass and a = ?Original_a and b = ?Original_b and c = ?Original_c and d = ?Original_d and e = ?Original_e and f = ?Original_f and g = ?Original_g and h = ?Original_h and i = ?Original_i and j = ?Original_j and k = ?Original_k and l = ?Original_l and m = ?Original_m and n = ?Original_n and o = ?Original_o and p = ?Original_p and q = ?Original_q and r = ?Original_r and s = ?Original_s and t = ?Original_t and u = ?Original_u and v = ?Original_v and w = ?Original_w and x = ?Original_x and y = ?Original_y and z = ?Original_z", con)
cmd.Parameters.AddWithValue("username", tb_username.Text)
cmd.Parameters.AddWithValue("userpass", tb_userpass.Text)
cmd.Parameters.AddWithValue("a", cb_a.Checked)
cmd.Parameters.AddWithValue("b", cb_b.Checked)
cmd.Parameters.AddWithValue("c", cb_c.Checked)
cmd.Parameters.AddWithValue("d", cb_d.Checked)
cmd.Parameters.AddWithValue("e", cb_e.Checked)
cmd.Parameters.AddWithValue("f", cb_f.Checked)
cmd.Parameters.AddWithValue("g", cb_g.Checked)
cmd.Parameters.AddWithValue("h", cb_h.Checked)
cmd.Parameters.AddWithValue("i", cb_i.Checked)
cmd.Parameters.AddWithValue("j", cb_j.Checked)
cmd.Parameters.AddWithValue("k", cb_k.Checked)
cmd.Parameters.AddWithValue("l", cb_l.Checked)
cmd.Parameters.AddWithValue("m", cb_m.Checked)
cmd.Parameters.AddWithValue("n", cb_n.Checked)
cmd.Parameters.AddWithValue("o", cb_o.Checked)
cmd.Parameters.AddWithValue("p", cb_p.Checked)
cmd.Parameters.AddWithValue("q", cb_q.Checked)
cmd.Parameters.AddWithValue("r", cb_r.Checked)
cmd.Parameters.AddWithValue("s", cb_s.Checked)
cmd.Parameters.AddWithValue("t", cb_t.Checked)
cmd.Parameters.AddWithValue("u", cb_u.Checked)
cmd.Parameters.AddWithValue("v", cb_v.Checked)
cmd.Parameters.AddWithValue("w", cb_w.Checked)
cmd.Parameters.AddWithValue("x", cb_x.Checked)
cmd.Parameters.AddWithValue("y", cb_y.Checked)
cmd.Parameters.AddWithValue("z", cb_z.Checked)
cmd.Parameters.AddWithValue("Original_username", hf_username.Value)
cmd.Parameters.AddWithValue("Original_userpass", hf_userpass.Value)
cmd.Parameters.AddWithValue("Original_a", hf_a.Value)
cmd.Parameters.AddWithValue("Original_b", hf_b.Value)
cmd.Parameters.AddWithValue("Original_c", hf_c.Value)
cmd.Parameters.AddWithValue("Original_d", hf_d.Value)
cmd.Parameters.AddWithValue("Original_e", hf_e.Value)
cmd.Parameters.AddWithValue("Original_f", hf_f.Value)
cmd.Parameters.AddWithValue("Original_g", hf_g.Value)
cmd.Parameters.AddWithValue("Original_h", hf_h.Value)
cmd.Parameters.AddWithValue("Original_i", hf_i.Value)
cmd.Parameters.AddWithValue("Original_j", hf_j.Value)
cmd.Parameters.AddWithValue("Original_k", hf_k.Value)
cmd.Parameters.AddWithValue("Original_l", hf_l.Value)
cmd.Parameters.AddWithValue("Original_m", hf_m.Value)
cmd.Parameters.AddWithValue("Original_n", hf_n.Value)
cmd.Parameters.AddWithValue("Original_o", hf_o.Value)
cmd.Parameters.AddWithValue("Original_p", hf_p.Value)
cmd.Parameters.AddWithValue("Original_q", hf_q.Value)
cmd.Parameters.AddWithValue("Original_r", hf_r.Value)
cmd.Parameters.AddWithValue("Original_s", hf_s.Value)
cmd.Parameters.AddWithValue("Original_t", hf_t.Value)
cmd.Parameters.AddWithValue("Original_u", hf_u.Value)
cmd.Parameters.AddWithValue("Original_v", hf_v.Value)
cmd.Parameters.AddWithValue("Original_w", hf_w.Value)
cmd.Parameters.AddWithValue("Original_x", hf_x.Value)
cmd.Parameters.AddWithValue("Original_y", hf_y.Value)
cmd.Parameters.AddWithValue("Original_z", hf_z.Value)
Response.Write(cmd.CommandText)
Try
con.Open()
Dim i As Integer = cmd.ExecuteNonQuery()
If i > 0 Then
Response.Write("更新成功")
Else
Response.Write("更新失败")
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Using
End Using
Me.GridView1.EditIndex = -1
Me.BindData()
End Sub
End Class
里面有错误update不成功
猜你喜欢
转载自blog.csdn.net/eds124/article/details/88380789
今日推荐
周排行