各位大侠,问个问题,我在改变表中的一条记录时,老出问题:
各位大侠,问个问题,我在改变表中的一条记录时,老出问题:表中的三条字段如下
BorrowNo CardNo BorrowDate
文本 文本 日期/时间
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim connstr, updatetcmd As String
connstr = "provider=microsoft.jet.oledb.4.0;data source=Books.mdb"
Dim conn As OleDbConnection, cmd As OleDbCommand
conn = New OleDbConnection(connstr)
conn.Open()
updatetcmd = "update borrow set (CardNo=@CardNo ,BorrowDate=@BorrowDate) where (BorrowNo=@BorrowNo)"
cmd = New OleDbCommand(updatetcmd, conn)
cmd.Parameters.Add(New OleDbParameter("@CardNo", OleDbType.VarChar))
cmd.Parameters.Add(New OleDbParameter("@BorrowDate", OleDbType.DBDate))
cmd.Parameters.Add(New OleDbParameter("@BorrowNo", OleDbType.VarChar))
cmd.Parameters("@CardNo").Value = TextBox2.Text
cmd.Parameters("@BorrowDate").Value = Convert.ToDateTime(TextBox3.Text)
cmd.Parameters("@BorrowNo").Value = TextBox1.Text
cmd.ExecuteNonQuery()
conn.Close()
showperson()
End Sub
Public Function showperson()
Dim connstr, selectcmd As String
connstr = "provider=microsoft.jet.oledb.4.0;data source=Books.mdb"
selectcmd = "select * from borrow"
Dim conn As OleDbConnection, myadpter As OleDbDataAdapter
Dim mydataset As New DataSet
conn = New OleDbConnection(connstr)
conn.Open()
myadpter = New OleDbDataAdapter(selectcmd, conn)
myadpter.Fill(mydataset, "borrow")
DataGrid1.DataSource = mydataset.Tables("borrow")
End Function
运行时提示cmd.ExecuteNonQuery()出错
未处理的“System.Data.OleDb.OleDbException”类型的异常出现在 system.data.dll 中。
烦恼