你好,我想知道如何使用linq將datagridview中的行保存到數據庫中。 我的datagridview包含兩列:CustomerID和Customer。另外我的數據庫包含這兩列:CustomerID和Customer。如何將datagridview保存到數據庫使用linq
private void saveToolStripButton_Click_1(object sender, EventArgs e)
{
Customer.EndEdit();
kundhandler.customername();
kundhandler.SubmitChanges();
MessageBox.Show("Customer save");
}
public void CustomerName()
{
db.CustomerName();
}
public void SubmitChanges()
{
db.SubmitChanges();
}
DataContext db = new DataContext();
public void CustomerName()
{
var qry = from i in db.Customer
select i;
db.SubmitChanges();
}
public void SubmitChanges()
{
db.SubmitChanges();
}
檢查這有助於你http://www.c-sharpcorner.com/uploadfile/kannagoud/insertupdatedelete-in-datagridview-using-linq-in- windows-forms/ –