devexpress c#更新sql数据库
我更新数据库时遇到问题。。当我计算单价和Lprofit时,我只在GridView中看到了值,但在SQL数据库中什么也没有看到。。那么如何自动更新呢devexpress c#更新sql数据库,c#,sql,devexpress,C#,Sql,Devexpress,我更新数据库时遇到问题。。当我计算单价和Lprofit时,我只在GridView中看到了值,但在SQL数据库中什么也没有看到。。那么如何自动更新呢 private void Chillers_Load(object sender, EventArgs e) { // TODO: This line of code loads data into the 'chillersDataSet1.OrnekTbl' table. You can move, or remove it, as ne
private void Chillers_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'chillersDataSet1.OrnekTbl' table. You can move, or remove it, as needed.
this.ornekTblTableAdapter1.Fill(this.chillersDataSet1.OrnekTbl);
// TODO: This line of code loads data into the 'chillersDataSet.OrnekTbl' table. You can move, or remove it, as needed.
this.ornekTblTableAdapter.Fill(this.chillersDataSet.OrnekTbl);
try
{
this.Validate();
this.ornekTblTableAdapter.Update(this.chillersDataSet.OrnekTbl);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
InitMDBData();
for (int i = 0; i < gridView1.RowCount; i++)
{
var totalprice = Convert.ToDecimal(gridView1.GetRowCellValue(i, "TotalPrice"));
var quantity = Convert.ToDecimal(gridView1.GetRowCellValue(i, "Quantity"));
gridView1.SetRowCellValue(i, "UnitPrice", (totalprice / quantity));
}
for (int i = 0; i < gridView1.RowCount; i++)
{
var totPrice = Convert.ToDecimal(gridView1.GetRowCellValue(i, "TotPrice"));
var totalPrice = Convert.ToDecimal(gridView1.GetRowCellValue(i, "TotalPrice"));
gridView1.SetRowCellValue(i, "Lprofit", (totPrice - totalPrice));
this.ornekTblTableAdapter1.Update(this.chillersDataSet1.OrnekTbl);
}
}
private void columers\u加载(对象发送方,事件参数e)
{
//TODO:这行代码将数据加载到'ColumersDataSet1.OrnekTbl'表中。您可以根据需要移动或删除它。
this.ornektbletadapter1.Fill(this.columersdataset1.OrnekTbl);
//TODO:这行代码将数据加载到'ColumersDataSet.OrnekTbl'表中。您可以根据需要移动或删除它。
this.ornektbletadapter.Fill(this.columersdataset.OrnekTbl);
尝试
{
这个。Validate();
this.ornektbltadapter.Update(this.columersdataset.OrnekTbl);
}
捕获(例外情况除外)
{
MessageBox.Show(例如Message);
}
InitMDBData();
对于(int i=0;i
您正在调试或运行编译的软件吗?
VisualStudio中的默认设置是,调试时,它将创建数据库的副本,并且您所做的每个更改都不会保存到实际的数据库中
在解决方案资源管理器中选择数据库,并将“复制到输出目录”更改为“如果更新,则复制”。这样,它将在debug中对数据库进行更改
编辑:查看您的源代码,我还可以看到您缺少一个更新调用。如果要写入数据库,请执行以下操作:
ornekTblTableAdapter.EndEdit();
ornekTblTableAdapter.Update();
(见:)