【发布时间】:2015-06-11 17:06:25
【问题描述】:
我的datagridview 中有一些数据。我想使用 LINQ 从datagridview 一次将所有这些数据插入数据库。但是,无法插入。
这是我的代码:
DetailTransaction dt = new DetailTransaction();
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
dt.TransactionID = labelID.Text;
dt.ProductID = dataGridView1.Rows[i].Cells[0].Value.ToString();
dt.Quantity = int.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString());
}
dc.DetailTransactions.InsertOnSubmit(dt);
dc.SubmitChanges();
谁能告诉我正确的代码是什么?
【问题讨论】: