我们在 MS-Access 中有交易吗?

Do we have transactions in MS-Access?(我们在 MS-Access 中有交易吗?)
本文介绍了我们在 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 中有交易吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)