i have ms access database in that i have different tables. I want to enter values through windows form application in database . can anyone suggest me how to do coding for above requirement in VB.net . I am using Visual studio 2010 express edition.
-
Please show some effort before posting. There are millions of links on this. Do you have done some research before? Do you have some code that doesn't work as you expect? Or are just sitting there waiting for someone to write the code for you?Steve– Steve2015-12-07 09:56:39 +00:00Commented Dec 7, 2015 at 9:56
-
InsertQuery = "INSERT INTO Table1table (L1,L2,L3,L4,L5,) VALUES (@L1,@L2,@L3,@L4,@L5)"Hannure– Hannure2015-12-07 10:17:15 +00:00Commented Dec 7, 2015 at 10:17
-
I am getting "Syntax error in INSERT INTO statement"Hannure– Hannure2015-12-07 10:17:50 +00:00Commented Dec 7, 2015 at 10:17
-
Oh, well we are making some advances. Now if you just edit your question showing the REAL code with the REAL column names and values that leads to the Syntax error we could help to fix itSteve– Steve2015-12-07 10:40:07 +00:00Commented Dec 7, 2015 at 10:40
-
Possible duplicate of How would I insert data into an Access table using vb.net?David Wilson– David Wilson2015-12-08 12:32:12 +00:00Commented Dec 8, 2015 at 12:32
Add a comment
|
1 Answer
for your reference...
Dim con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim rdr As OleDb.OleDbDataReader
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\DatabaseName.accdb;Persist Security Info=False;"
con.Open()
cmd = New OleDbCommand("INSERT INTO tableName (c1, c2) VALUES (@c1, @c2", con)
cmd.Parameters.AddWithValue("@c1", txtbox1.text)
cmd.Parameters.AddWithValue("@c2", txtbox2.text)
cmd.ExecuteNonQuery()