My Assistant
![]()
Custom Search
|
![]() ![]() |
![]() |
![]() Post#1 | |
Posts: 1,134 Joined: 19-February 08 ![]() | friends; if i have some commands with SYSTEM.IO MOVE file COPY file Delete file In Vb.net as example I want to execute all command if one of this command fails all process fail is this possible Thanks you |
![]() Post#2 | |
UtterAccess VIP Posts: 4,053 Joined: 19-October 10 ![]() | Well unless you have added some error handling one would assume that you would get a runtime error if one failed? Error handler seems to be the way to solve this regardless. |
![]() Post#3 | |
![]() UtterAccess VIP Posts: 11,253 Joined: 10-February 04 From: South Charleston, WV ![]() | Does it work ordinarily? Are you running this from VB.Net? Can you show the code? |
![]() Post#4 | |
![]() UA Admin Posts: 36,172 Joined: 20-June 02 From: Newcastle, WA ![]() | So, since you've posted this in the Visual Basic 2003 forum, are we to assume this is a VB.Net application? If so, look into the use of Transactions |
![]() Post#5 | |
Posts: 1,134 Joined: 19-February 08 ![]() | friends this what i want pseudo code string sourceDbSpec = @"C:\Users\Public\a.accdb"; string destinationDbSpec = @"C:\Users\Public\b.accdb"; // Required COM reference for project: // Microsoft Office 14.0 Access Database Engine Object Library var dbe = new Microsoft.Office.Interop.Access.Dao.DBEngine(); dbe.CompactDatabase(sourceDbSpec, destinationDbSpec); System.IO.File.Delete(sourceDbSpec); System.IO.File.Move("C:\Users\Public\b.accdb", destinationDbSpec ); i want run all this command at the same time without any problem as package using some think like transaction in SQL server |
![]() Post#6 | |
![]() UA Admin Posts: 36,172 Joined: 20-June 02 From: Newcastle, WA ![]() | Okay, did you go read the information on transactions to which I linked? If so, what part do you need help understanding? If not, please read it and see if you can implement it. |
![]() Post#7 | |
Posts: 1,134 Joined: 19-February 08 ![]() | GroverParkGeorge i read documentation and i'm use Transaction with Insert Delete Update with database but i'm not using transaction with command like CODE System.IO.File.Delete(sourceDbSpec); System.IO.File.Move("C:\Users\Public\b.accdb", destinationDbSpec ); is possible use Transaction with Delete , Move .net and when there is error in delete or move can rollback |
![]() Post#8 | |
![]() UA Admin Posts: 36,172 Joined: 20-June 02 From: Newcastle, WA ![]() | Well, the best way to know for sure is to try, isn't it? |
![]() Post#9 | |
Posts: 1,134 Joined: 19-February 08 ![]() | not work with System.IO CODE OleDbTransaction transaction; try { dataConnection db = new dataConnection(); db.cn.Open(); // int successdTransation = 0; transaction = db.cn.BeginTransaction(); System.IO.File.Move(@"H:\b.txt", @"d:\db\b.txt"); System.IO.Directory.Delete(@"H:\db"); transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); MessageBox.Show(ex.Message); } |
![]()
Custom Search
|
![]() | Search Top Lo-Fi | 8th December 2019 - 08:37 AM |