主题:System.Data.OleDb.OleDbException: 标准表达式中数据类型不匹配。
Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
Dim aa As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim bb As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim cc As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim dd As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db1.mdb")
myConn = New OleDbConnection(strConn)
Dim updatestring As String
updatestring = "update yhxx set id=@id,yhm=@yhm,mm=@mm,lx=@lx where id=" & DataGrid1.DataKeys(e.Item.ItemIndex)
Dim aaaa As OleDbCommand = New OleDbCommand(updatestring, myConn)
aaaa.Parameters.Add("@id", OleDbType.VarChar, 50).Value = aa
aaaa.Parameters.Add("@yhm", OleDbType.VarChar, 50).Value = bb
aaaa.Parameters.Add("@mm", OleDbType.VarChar, 50).Value = cc
aaaa.Parameters.Add("@lx", OleDbType.VarChar, 50).Value = dd
myConn.Open()
aaaa.ExecuteNonQuery()
myConn.Close()
DataGrid1.EditItemIndex = -1
bind_data()
End Sub[em18]
Dim aa As String = CType(e.Item.Cells(1).Controls(0), TextBox).Text
Dim bb As String = CType(e.Item.Cells(2).Controls(0), TextBox).Text
Dim cc As String = CType(e.Item.Cells(3).Controls(0), TextBox).Text
Dim dd As String = CType(e.Item.Cells(4).Controls(0), TextBox).Text
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db1.mdb")
myConn = New OleDbConnection(strConn)
Dim updatestring As String
updatestring = "update yhxx set id=@id,yhm=@yhm,mm=@mm,lx=@lx where id=" & DataGrid1.DataKeys(e.Item.ItemIndex)
Dim aaaa As OleDbCommand = New OleDbCommand(updatestring, myConn)
aaaa.Parameters.Add("@id", OleDbType.VarChar, 50).Value = aa
aaaa.Parameters.Add("@yhm", OleDbType.VarChar, 50).Value = bb
aaaa.Parameters.Add("@mm", OleDbType.VarChar, 50).Value = cc
aaaa.Parameters.Add("@lx", OleDbType.VarChar, 50).Value = dd
myConn.Open()
aaaa.ExecuteNonQuery()
myConn.Close()
DataGrid1.EditItemIndex = -1
bind_data()
End Sub[em18]