本文介绍了以vb格式访问Ms db的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的所有
请帮助将数据插入我的访问数据库,我需要代码将数据插入msaccess db
im在数据库中使用msaccess开发一个项目但是我无法在我的代码下方插入,请帮助我做错了。
这是我的代码
Dear All
Please help to insert data to my access db,i need code for insert data to msaccess db
i m developing one project in database i m using for msaccess but i am unable to insert below my code posing please help were i m doing mistake.
This is My Code
Public Class Party
Dim cnnOLEDB As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\webapps\ArrowJet\CP.mdb")
Dim cmdOLEDB As New OleDbCommand
Dim cmdInsert As New OleDbCommand
Dim cmdUpdate As New OleDbCommand
Dim cmdDelete As New OleDbCommand
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim InsertQuery As String
InsertQuery = "INSERT INTO party (PartyName, PartyAccount, PayTo,PartyInfo) VALUES (@PartyName, @PartyAccount, @PayTo,@PartyInfo)"
Dim cmd As OleDbCommand = New OleDbCommand(InsertQuery, cnnOLEDB)
cmd.Parameters.AddWithValue("@PartyName", ComboBox1.Text)
cmd.Parameters.AddWithValue("@PartyAccount", paTextBox2.Text)
cmd.Parameters.AddWithValue("@PayTo", ptTextBox3.Text)
cmd.Parameters.AddWithValue("@PartyInfo", pfTextBox4.Text)
cnnOLEDB.Open()
cmdOLEDB = New OleDbCommand(InsertQuery, cnnOLEDB)
cmdOLEDB.ExecuteNonQuery()
cnnOLEDB.Close()
Catch ex As Exception
MessageBox.Show("Record Added")
End Try
推荐答案
这篇关于以vb格式访问Ms db的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!