在C#.net中的表格中插入组合框值 [英] Inserting combobox values in table from C#.net
问题描述
我在Access.Front中创建了2个表。我正在使用Windows Form Application我设计了3个Textbox。我的查询需要在第一个表和第二个表中插入前两个文本框值。如何处理这个过程。我已经尝试了下面的编码,但它不起作用,
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();
问候
Balamurugan
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
推荐答案
yu插入文本框值.....你需要只插入combox val; ues right ......
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 /论坛/ zh / winformsdatacontrols / thread / 7d447ecc-5506-429b-907b-bbaf43313be6 [ ^ ]
OleDbCommand cmd = new OleDbCommand(INSERT INTO tablename([column1] ],[C2])VALUES(''+ textBox1.Text +'',''+ textBox1.Text +''),con);
cmd.ExecuteNonQuery() ;
OleDbCommand cmd1 =新的OleDbCommand(INSERT INTO tablename2([column1])VALUES(''+ textBox3.Text +''),con);
cmd1.ExecuteNonQuery();
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();
这篇关于在C#.net中的表格中插入组合框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!