UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Transaction With Vb.net Commands, 2017    
 
   
access2009eg
post Jan 8 2018, 10:41 AM
Post#1



Posts: 964
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




--------------------
I would like to Thank you for your help
Go to the top of the page
 
JonSmith
post Jan 8 2018, 10:43 AM
Post#2



Posts: 3,222
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.
Go to the top of the page
 
projecttoday
post Jan 8 2018, 11:24 AM
Post#3


UtterAccess VIP
Posts: 8,800
Joined: 10-February 04
From: South Charleston, WV


Does it work ordinarily? Are you running this from VB.Net? Can you show the code?

--------------------
Robert Crouser

Go to the top of the page
 
GroverParkGeorge
post Jan 8 2018, 01:05 PM
Post#4


UA Admin
Posts: 31,549
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

--------------------
Go to the top of the page
 
access2009eg
post Jan 9 2018, 08:40 AM
Post#5



Posts: 964
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

--------------------
I would like to Thank you for your help
Go to the top of the page
 
GroverParkGeorge
post Jan 9 2018, 08:51 AM
Post#6


UA Admin
Posts: 31,549
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.

--------------------
Go to the top of the page
 
access2009eg
post Jan 9 2018, 09:48 AM
Post#7



Posts: 964
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


--------------------
I would like to Thank you for your help
Go to the top of the page
 
GroverParkGeorge
post Jan 9 2018, 10:10 AM
Post#8


UA Admin
Posts: 31,549
Joined: 20-June 02
From: Newcastle, WA


Well, the best way to know for sure is to try, isn't it?


--------------------
Go to the top of the page
 
access2009eg
post Jan 9 2018, 02:57 PM
Post#9



Posts: 964
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);
            }

--------------------
I would like to Thank you for your help
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    16th January 2018 - 06:45 AM