private void OnSqlUpdating(Object source, SqlDataSourceCommandEventArgs e) {
DbCommand command = e.Command;
DbConnection cx = command.Connection;
cx.Open();
DbTransaction tx = cx.BeginTransaction();
command.Transaction = tx;
} private void OnSqlUpdated(Object source, SqlDataSourceStatusEventArgs e) {
DbCommand command = e.Command;
DbTransaction tx = command.Transaction;
// In this code example the OtherProcessSucceeded variable represents
// the outcome of some other process that occurs whenever the data is
// updated, and must succeed for the data change to be committed. For
// simplicity, we set this value to true.
bool OtherProcessSucceeded = true;
if (OtherProcessSucceeded) {
tx.Commit();
Label2.Text="The record was updated successfully!";
}
else {
tx.Rollback();
Label2.Text="The record was not updated.";
}
}
DbCommand command = e.Command;
DbConnection cx = command.Connection;
cx.Open();
DbTransaction tx = cx.BeginTransaction();
command.Transaction = tx;
} private void OnSqlUpdated(Object source, SqlDataSourceStatusEventArgs e) {
DbCommand command = e.Command;
DbTransaction tx = command.Transaction;
// In this code example the OtherProcessSucceeded variable represents
// the outcome of some other process that occurs whenever the data is
// updated, and must succeed for the data change to be committed. For
// simplicity, we set this value to true.
bool OtherProcessSucceeded = true;
if (OtherProcessSucceeded) {
tx.Commit();
Label2.Text="The record was updated successfully!";
}
else {
tx.Rollback();
Label2.Text="The record was not updated.";
}
}
解决方案 »
- 使用右键菜单弹出保存对话框的时候,右键菜单不消失,怎么办?
- 请教usercontrol 不触发界面的问题
- 求救,急死了......
- 用xmldocument load进来一个xml文件修改后save()。。在load进来的时候,看到的是修改以前的状态,但xml实际上改了,????????、
- 到底是搞C/S模式赚钱,还是搞B/S模式赚钱?
- 注册用户时,当用户名已存在且该用户已输入密码,验证后能否将密码继续保留在文本框内?
- 求一个sql语句!哪位大哥帮帮忙
- 在.rdl报表中定义了参数,如何在已经加入了ReportViewer控件的.aspx窗体中给参数赋值。只要对Reporting Server有点研究的朋友都来支持一
- 在线等关于missbbs的问题。
- 高手来帮看一下 这个button_click过程错在哪里,谢谢(asp.net)
- 求 SqlParameter 用法和使用时机
- 怎么给网站中每一个页面加头加尾?
前一个方法表示在update数据之前,实现启用事务处理。后一个方法表示在更新完成之后,则判断是否实现了更新。如果更新成功,则并显示相关信息;否则回调,并显示相关信息。
我们要注意到,在asp.net 2.0中更新数据时,一般不需要显示调用更新方法,这是自动完成的(虽然asp.net 2.0提供了这个方法)。在此,我们重点处理的是更新前后的内容。