问题描述
我正在使用 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 中有交易吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!