Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
868 views
in Technique[技术] by (71.8m points)

create a transaction for MS Access in c#

I need some code in my c# application to implement a transaction using Microsoft Access database

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

OleDbTransaction class is made just for that. You can create one by calling BeginTransaction on your OleDbConnection object then Commit or Rollback up to your scenario

using (var transaction = cn.BeginTransaction()) {
  //Do Stuff here using the connection
  transaction.Commit();
}

The transaction will be rolled back at dispose if no commit has been called.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...