在C#中由其他用户刷新数据库中数据更改的前端

时间:2015-08-31 05:50:45

标签: c# sql-server-2008

我使用C#作为前端,有多个用户,连接到SQL Server 2008.我的问题是:如果一个用户使用更新操作更改数据,其他用户如何看到该更新语句的影响使用Select *命令或sda.fill

我的桌子上有成千上万的记录,这些记录在重新填充时花费了太多时间。

以下是我用来更新数据的代码。

MyGlobalVariables.bsInc.EndEdit();
MyGlobalVariables.con.Open();
MyGlobalVariables.CmdString = "Update Increment set IncAmount=" + Convert.ToInt32(txtInc.Text) + ", EditedBy='"+MyGlobalVariables.MyUname+"', editedOn=sysdatetime() where IncYear=" + Convert.ToInt16(cmbIncYear.Text) + " and EmpCode='" + MyGlobalVariables.MyEmpCode + "'";
MyGlobalVariables.cmd = new SqlCommand(MyGlobalVariables.CmdString, MyGlobalVariables.con);
MyGlobalVariables.cmd.ExecuteNonQuery();
MyGlobalVariables.con.Close();
MyGlobalVariables.ds.Tables["Increment"].Rows[MyGlobalVariables.bsInc.Position].AcceptChanges();
MyGlobalVariables.MyParentForm.lblProg.Text = "Record Updated Successfully.";

1 个答案:

答案 0 :(得分:0)

我找到了解决问题的方法。这是插入过程后的代码。

{{1}}

感谢大家的建议。

相关问题