Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi,
I have created a 2 tables in Access.Front End i'm using Windows Form Application i have designed 3 Textbox. My Query is need to insert first 2 textbox values in 1st table and 2nd table.How to work on this process.I have tried the below coding but it is not working,

con.Open();
OleDbCommand cmd = new OleDbCommand("INSERT INTO SupplierMaster VALUES('" + textBox2.Text + "','" + textBox1.Text + "')", con);
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO wtDetail VALUES [SupCode]='" + textBox2.Text + "'", con);
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
con.Close();

Regards
Balamurugan
Posted
Updated 17-Jan-13 20:01pm
v2
Comments
Deenuji 18-Jan-13 1:51am    
wat r the fields u ve in this two tables???? wats the error u getting now?
Balamurugan1989 18-Jan-13 1:59am    
I'm not getting any error but the values is not getting inserted.First column and second column should save in both the tables.For this i have asked the query.
Deenuji 18-Jan-13 2:02am    
u want to insert textbox values or comboboxvalues????
Balamurugan1989 18-Jan-13 2:04am    
Textbox values i have updated the question.
Deenuji 18-Jan-13 2:09am    
OleDbCommand cmd = new OleDbCommand("INSERT INTO tablename ([column1],[C2]) VALUES('" +textBox1.Text + "','" + textBox1.Text + "')", con);
cmd.ExecuteNonQuery();
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO tablename2([column1]) VALUES('" +textBox3.Text + "')", con);
cmd1.ExecuteNonQuery();

y u inserting textbox values.....u need to insert only combox val;ues right.....

OleDbCommand cmd = new OleDbCommand("INSERT INTO SupplierMaster VALUES('" + combox1.selecteditem.text + "','" + combox2.selecteditem.text + "')", con);




http://social.msdn.microsoft.com/Forums/zh/winformsdatacontrols/thread/7d447ecc-5506-429b-907b-bbaf43313be6[^]
 
Share this answer
 
v2
OleDbCommand cmd = new OleDbCommand("INSERT INTO tablename ([column1],[C2]) VALUES('" +textBox1.Text + "','" + textBox1.Text + "')", con);
cmd.ExecuteNonQuery();
OleDbCommand cmd1 = new OleDbCommand("INSERT INTO tablename2([column1]) VALUES('" +textBox3.Text + "')", con);
cmd1.ExecuteNonQuery();
 
Share this answer
 
Comments
fjdiewornncalwe 21-Feb-13 16:43pm    
My 1: SQL Injection Nightmare.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900