发生错误时如何防止保存数据 [英] how to prevent saving data when an error occurred

查看:105
本文介绍了发生错误时如何防止保存数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果要在数据库中的多个表中插入和更新数据,该怎么办,以确保如果在应用程序中插入或更新命令时发生问题,则这些表不会被更改

What do you need to do if you will insert and update data in more than one table in the database to make sure that if a problem happened during inserting or updating a command in your application, the tables don''t be changed ??

推荐答案

阅读 SQL事务.

此处:用于ADO.NET方式的SqlTransaction类 [ ^ ]
BEGIN事务-数据库方式 [ COMMIT事务-数据库方式 [
Read on SQL Transaction.

Here: SqlTransaction Class for ADO.NET way[^]
BEGIN Transaction - DB way[^]
COMMIT Transaction - DB way[^]

Using them, if needed, you can either commit all or rollback all based on failure of any one.


这篇关于发生错误时如何防止保存数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆