将sql的数据显示在gridview中,更改了gridview中的数据,为什么sql中的数据不能更改?
Protected Sub GridView1_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView1.RowUpdating
Dim connstring As SqlConnection
connstring = New SqlConnection( "data source=yaozc;initial catalog=ssenior;integrated security=true ")
' Dim connstring As String = "data source=yaozc;initial catalog=ssenior;integrated security=true "
Dim sqlstring As String = "select * from examfinish "
Dim sqldataadapter1 As New SqlDataAdapter(sqlstring, connstring)
connstring.Open()
Dim dataset1 As New DataSet()
sqlstr = "UPDATE examfinish SET remark = @remark " + "WHERE name = @name "
sqldataadapter1.Fill(dataset1, "examfinish ")
sqldataadapter1.UpdateCommand = New SqlCommand(sqlstr, connstring)
sqldataadapter1.UpdateCommand.Parameters.Add( "@remark ", SqlDbType.NVarChar, 20, "remark ")
sqldataadapter1.UpdateCommand.Parameters.Add( "@name ", SqlDbType.NVarChar, 20, "name ")
sqldataadapter1.Update(dataset1, "examfinish ")
GridView1.DataSource = dataset1.Tables( "examfinish ").DefaultView
GridView1.DataBind()
connstring.Close()
------解决方案--------------------Protected Sub GridView2_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GridView2.RowUpdating
If IsNumeric(CType(GridView2.Rows(e.RowIndex).FindControl( "TextBox3 "), TextBox).Text) = False Then
Response.Write( " <script language=javascript> alert( '必须输入数字!! ');history.go(-1) </script> ")
Response.End()
End If
Dim conn As String = System.Configuration.ConfigurationManager.ConnectionStrings( "znhConnectionStringall ").ToString
Dim comm As SqlCommand
comm = New SqlCommand( "update cust_item set item_xcpage= ' " & CType(GridView2.Rows(e.RowIndex).FindControl( "TextBox4 "), TextBox).Text & " ',item_jzpage= ' " & CType(GridView2.Rows(e.RowIndex