本文介绍了无法使用linq将wpf datagridview单元格数据更新到sql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void btnUpdate_Click(object sender, RoutedEventArgs e)
{
try
{
comocoLTSDataContext dc = new comocoLTSDataContext();
DCdate dateRow = dataGrid1.SelectedValue as DCdate;
//int m = dateRow.GKId;
DCdate date = (from d in dc.DCdates
where d.GKId == dateRow.GKId & d.DId==dateRow.DId & d.DCcontainer.ContainerNo==txtContNo.Text
select d).Single();
date.Date1 = dateRow.Date1;
date.Temp00 = dateRow.Temp00;
date.Temp06 = dateRow.Temp06;
date.Temp12 = dateRow.Temp12;
date.Temp18 = dateRow.Temp18;
date.DLane = dateRow.DLane;
date.DVentilation = dateRow.DVentilation;
date.DRemarks = dateRow.DRemarks;
dc.SubmitChanges();
MessageBox.Show("Row Updated Successfully");
LoadDates();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
return;
}
}
这就是我尝试使用datagridview更新数据库的方式.代码似乎还可以.还给出行更新"消息.但是当调用LoadDates()Db尚未更新时.
请尽快帮助我...
为什么没人能给我一个理由.....
this is how I tried to update my db using datagridview. code seems to be ok. also giving the "Row updated" message. but when call LoadDates() Db has not been updated.
please help me soon...
why can''t anyone give me a reason.....
推荐答案
这篇关于无法使用linq将wpf datagridview单元格数据更新到sql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!