本文介绍了使用VB.NET Windows窗体更新MS Access数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个简单的Access数据库,想要使用VB.NET窗体来更新tbl数据。我一直收到错误,即cmd.ExecuteNonQuery()无法执行。 这是代码。任何想法? 受保护的子按钮1_Click(ByVal发送者作为对象,ByVal e As System.EventArgs)处理Button1.Click   ;       Dim strConnectionString =" Provider = Microsoft.Jet.OLEDB.4.0; Data Source = {My Database} .mdb; Persist Security Info = False"       Dim cnnOLEDB As New OleDbConnection(strConnectionString)       Dim cmdOLEDB As New OleDbCommand       Dim cmdInsert As New OleDbCommand       Dim cmdUpdate As New OleDbCommand       Dim cmdDelete As New OleDbCommand       Dim InsertQuery As String       cnnOLEDB.Open()           InsertQuery =" INSERT tblItem SET(Indate,StkLoc,UPC,Desc,SN,Cond,RetPrice,Cost)VALUES(@ Inndate,@ StkLoc,@ UPC,@ Desc,@ SN,@ Cant,@ RetPrice,@ Cost) WHERE [email protected])"       Dim cmd As OleDbCommand = New OleDbCommand(InsertQuery,cnnOLEDB)       cmd.Parameters.AddWithValue(" @ InDate",TextBox1.Text)       cmd.Parameters.AddWithValue(" @ Item",TextBox2.Text)       cmd.Parameters.AddWithValue(" @ StkLoc",TextBox3.Text)       cmd.Parameters.AddWithValue(" @ UPC",TextBox9.Text)       cmd.Parameters.AddWithValue(" @ Desc",TextBox4.Text)       cmd.Parameters.AddWithValue(" @ SN",TextBox5.Text)       cmd.Parameters.AddWithValue(" @ Cond",TextBox6.Text)       cmd.Parameters.AddWithValue(" @ RetPrice",TextBox7.Text)       cmd.Parameters.AddWithValue(" @ Cost",TextBox8.Text)       cmd.ExecuteNonQuery()       cnnOLEDB.Close()       MessageBox.Show(" Item Update Complete。)       Me.Close() 解决方案 I have a simple Access database and want to use VB.NET windows form to update tbl data. I keep getting an error that cmd.ExecuteNonQuery() can not be executed.Here is the code. Any ideas? Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={My Database}.mdb;Persist Security Info=False" Dim cnnOLEDB As New OleDbConnection(strConnectionString) Dim cmdOLEDB As New OleDbCommand Dim cmdInsert As New OleDbCommand Dim cmdUpdate As New OleDbCommand Dim cmdDelete As New OleDbCommand Dim InsertQuery As String cnnOLEDB.Open() InsertQuery = "INSERT tblItem SET (Indate, StkLoc ,UPC,Desc, SN, Cond, RetPrice, Cost) VALUES (@Indate, @StkLoc , @UPC, @Desc, @SN, @Cond, @RetPrice, @Cost)WHERE [email protected])" Dim cmd As OleDbCommand = New OleDbCommand(InsertQuery, cnnOLEDB) cmd.Parameters.AddWithValue("@InDate", TextBox1.Text) cmd.Parameters.AddWithValue("@Item", TextBox2.Text) cmd.Parameters.AddWithValue("@StkLoc", TextBox3.Text) cmd.Parameters.AddWithValue("@UPC", TextBox9.Text) cmd.Parameters.AddWithValue("@Desc", TextBox4.Text) cmd.Parameters.AddWithValue("@SN", TextBox5.Text) cmd.Parameters.AddWithValue("@Cond", TextBox6.Text) cmd.Parameters.AddWithValue("@RetPrice", TextBox7.Text) cmd.Parameters.AddWithValue("@Cost", TextBox8.Text) cmd.ExecuteNonQuery() cnnOLEDB.Close() MessageBox.Show("Item Update Complete.") Me.Close() 解决方案 这篇关于使用VB.NET Windows窗体更新MS Access数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-05 22:46