Last post Sep 10, 2011 07:15 AM by Dora743
Sep 10, 2011 02:08 AM|Dora743|LINK
Hi all i would like to use MySqlTransaction in my requirement. Actually i am having a doubt regarding that i.e as per my requirement i will have to delete different values from database.
The process i am doing is as follows. Assume that i am having 2 EmpIDs where this EmpID will hold different values which may be multiple. I will store the corresponding values for that particular EmpID using Dictionary and then i will save them to a list corresponding
to the EmpID.
Assume that i am having list element as follows
For EmpID 1 i will have 1,2. I will check for the maximum value from the datbase in this list if exists i would like to delete this EmpID from the database.
For EmpID 2 i will have 1,2. But in my database i will have 3 as maximum values. So this one fails . I would like to rollback the previously deleted item .
Is it possible to do with a transaction if so can any one help me in solving this
Sample i code
obj.delete("storeprocname"); // this will occur when my list has maximum value
//Here i would like to rollback my previous one referring to the delete method in class file }
Sep 10, 2011 02:12 AM|PNasser|LINK
I think the way you want to handle this is inside a transaction, but no rolling back would be required, here's some psudo code:
MySqlTransaction scope = new MySqlTranscation();
check database for max value
if (should we insert this value)
Sep 10, 2011 02:13 AM|Dora743|LINK
I will enter to that code when max list was found for the employee.
Sep 10, 2011 07:15 AM|Dora743|LINK
Hmm i think no one understand my question clearly so in simple scenario i am saying
i am having a form which will have 2 text boxes and button when i click on button i would like to insert the text entered in the text boxes to database as separate rows.
Assume i will have a bool value to pass while inserting if i give true for the first item it will get inserted, i will give false to the second one which i would like to insert. As i am having false i don't want to insert this so i have to roll back the previous
a sample code
if(i==1 && flag==true)
if(j==1 && flag==false)