我们在 MS-Access 中有事务吗? [英] Do we have transactions in MS-Access?
问题描述
我正在使用 C#.NET 和 MS-Access 开发一个小型桌面应用程序.我之前没有任何 MS-Access 经验.我想知道我们是否可以在 Ms-Access 中使用事务.
I am developing a small desktop application using C#.NET and MS-Access. I don't have any prior experience of MS-Access. I want to know if we can use transactions in Ms-Access or not.
我有下面提到的情况.
插入Tbl1
插入Tbl2
Insert in Tbl1
Insert in Tbl2
我想只有在tbl1插入成功时才插入tbl2.如果在tbl2中插入时出现异常,我想回滚tbl1中的插入.
我知道这可以在 sql-server 中轻松实现,但是在 ms-access 的情况下,我应该如何管理.请帮助,提前致谢.
I want to insert in tbl2 only when insertion in tbl1 is successful. And if there is some exception during insertion in tbl2, I want to rollback the insertion in tbl1.
I know this can easily be achieved in sql-server, but in case of ms-access, How should I manage this.
Please Help, Thanks in advance.
推荐答案
看起来像我们这样做:MSDN - TRANSACTION 语句 (Microsoft Access SQL)
交易不会自动开始.要开始交易,您必须明确使用:
Transactions are not started automatically. To start a transaction, you must do so explicitly using:
BEGIN TRANSACTION
通过提交事务期间执行的所有工作来结束事务:
Conclude a transaction by committing all work performed during the transaction:
COMMIT [TRANSACTION | WORK]
通过回滚事务期间执行的所有工作来结束事务:
Conclude a transaction by rolling back all work performed during the transaction:
ROLLBACK [TRANSACTION | WORK]
这篇关于我们在 MS-Access 中有事务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!