将列表框中的项目发送到数据库单元格 [英] Send items in listbox to database cell
本文介绍了将列表框中的项目发送到数据库单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含值的列表框,
单击按钮时,列表框中的所有项目都应该发送到数据库中的单个单元格....我不确定如何编写代码,请帮助..
for(int i = 0; i< CustLB.Items.Count; i ++)
{
ListBox item = new ListBox();
item.Text = CustLB.Items [i] .Text;
item.Value = CustLB.Items [i] .Value;
OleDbCommand lct = new OleDbCommand(UPDATE [CO] SET [OL] =(@ OL),MAcon);
lct.Parameters.AddWithValue(@ OLD,,);
lct.ExecuteNonQuery();
}
我尝试过:
for(int i = 0; i< CustLB.Items.Count; i ++)
{
ListBox item = new ListBox() ;
item.Text = CustLB.Items [i] .Text;
item.Value = CustLB.Items [i] .Value;
OleDbCommand lct = new OleDbCommand(UPDATE [CO] SET [OL] =(@ OL),MAcon);
lct.Parameters.AddWithValue(@ OLD,,);
lct.ExecuteNonQuery();
}
解决方案
这里已经回答: [ ^ 一>
I've got a listbox which will contain values,
When a button is clicked all items in listbox should be sent to a single cell in the database.... I'm not sure how to write the code, please help..
for (int i = 0; i < CustLB.Items.Count; i++) { ListBox item = new ListBox(); item.Text = CustLB.Items[i].Text; item.Value = CustLB.Items[i].Value; OleDbCommand lct = new OleDbCommand("UPDATE [CO] SET [OL] = (@OL)", MAcon); lct.Parameters.AddWithValue("@OLD", ","); lct.ExecuteNonQuery(); }
What I have tried:
for (int i = 0; i < CustLB.Items.Count; i++) { ListBox item = new ListBox(); item.Text = CustLB.Items[i].Text; item.Value = CustLB.Items[i].Value; OleDbCommand lct = new OleDbCommand("UPDATE [CO] SET [OL] = (@OL)", MAcon); lct.Parameters.AddWithValue("@OLD", ","); lct.ExecuteNonQuery(); }
解决方案
Already answered here: Send item in listbox to a single cell in database[^]
这篇关于将列表框中的项目发送到数据库单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文