Hi all i am doing a code to delete the selected employee from the gridview where i can get multiple empids for that i will check for the maximum payperiod if exists i will delete that record if not i will exit.
But in my requirement the statement goes to the procedure where i have written code to delete the record when maximum condition is true.
If i get one condition true and other condition false i would like to roll back the previous which i deleted . Will transaction allow me this kind of process.
My sample code
if(FInd(maxlst))
{
obj.delete(); // Here i wrote the logic to delete
}
else
{
// I would like rollback the previous which i deleted
I am using MYSQL can any one help me
}
Loading

Dorababu MekaPosted Sep 10, 2011, 6:36 AM
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 one too
a sample code
button click
{
string str="Dora";
string str1="Babu";
bool flag=true;
i=1,j=1;
if(i==1 && flag==true)
inser str;
flag=false;
if(j==1 && flag==false)
rollback
}
Abhimanyu K VatsaPosted Sep 10, 2011, 5:55 AM
if(Find(maxlst))
{
obj.insert(); //insert it in temp table
obj.delete(); //delete that
}
else
{
obj.rollback(); //get the data back to original table from temp table
}
Prabhu RajaPosted Sep 10, 2011, 5:38 AM
if(FInd(maxlst))
{
obj.delete(); // Here i wrote the logic to delete
}
else
{
// I would like rollback the previous which i deleted
ROLLBACK;
}
Dorababu MekaPosted Sep 10, 2011, 5:28 AM
Prabhu RajaPosted Sep 10, 2011, 5:27 AM