Android Question JRDC2 MySQL Begin Transaction, Commit, Rollback

zabayin

Member
Licensed User
Does jrdc2 Can Rollback Transaction if lost connection to MySQL Database from VPS Server ? (Not localhost)
I already search in this forum and sorry i can't find. i found executebatch method but it was not my requirement.
I can make transaction safely with the following code with C#.
The CRUD Operation not damage my data Even If my VPS Server down.

C#:
//Insert the person database with some data.

myCommand.CommandText = "INSERT INTO person_withdrawl(person_id,withdrawl_amount)VALUES("
+ Convert.ToInt32(lbl_PersonID.Text.Trim()) + ","
+ Convert.ToString(txt_WithDrawl_Amount.Text.Trim()) + ")";

myCommand.ExecuteNonQuery();

//Insert is Completed.


// Then I Update another Corresponding Table

myCommand.CommandText = "UPDATE person SET "
+ "cash_amount=cash_amount-" + Convert.ToInt32(txt_WithDrawl_Amount.Text.Trim()) + "";


myCommand.ExecuteNonQuery();

//If above are going well. I commit it.

myTrans.Commit();

// if something wrong (e.g - connection down ... Nothing damaged! Try Again Safely)


I want to do like with B4A. Can anyone Point me out this ? Thank you all.
 

zabayin

Member
Licensed User
Why not? It will create a single transaction for the commands and will rollback and changes if there is an error.
OOPS! seems I'm misunderstanding about single transaction can't be rollback and changes in database. thank you very much.
 
Upvote 0
Top