update 不能更新 access 急死了 快来帮帮我呀!
以下是代码
Private Sub dg_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dg.UpdateCommand
Dim mianji1 As String = CType(e.Item.Cells(0).Controls(0), TextBox).Text
Dim didian1 As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim jiage1 As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim shuidian1 As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim wuye1 As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim chaoyang1 As String = CType(e.Item.Cells(5).Controls(0), TextBox).Text
Dim cheku1 As String = CType(e.Item.Cells(6).Controls(0), TextBox).Text
Dim louceng1 As String = CType(e.Item.Cells(7).Controls(0), TextBox).Text
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
conn = New OleDbConnection( "Provider=Microsoft.Jet.OleDb.4.0;Data Source= " & Server.MapPath( "logon.mdb "))
cmd = New OleDbCommand( "update chushou set mianji= ' " & mianji1 & " ',didian= ' " & didian1 & " ',jiage= ' " & jiage1 & " ',shuidian= ' " & shuidian1 & " ',wuye= ' " & wuye1 & " ',chaoyang= ' " & chaoyang1 & " ',cheku= ' " & cheku1 & " ',louceng= ' " & louceng1 & " ' where mianji= ' " & mianji1 & " ' ", conn)
Try
conn.Open()
Dim i As Integer = cmd.ExecuteNonQuery()
If i > 0 Then
Response.Write( " <script language= 'javascript '> alert( '修改成功! ') </script> ")
Else