Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want do differnt command text on database in different place , if one of this operation not complete rollback another command
Posted
Comments
[no name] 18-Mar-13 17:10pm    
Okay so use a transaction
Sergey Alexandrovich Kryukov 18-Mar-13 17:14pm    
You need to […] verbs, otherwise no one will be able to […] your questions. If some or all of the verbs are missing from your post, it cannot […] a well-formed question.
To […] about verbs, please […] this article:

http://en.wikipedia.org/wiki/Verb[^]

However, even with proper use verbs, I doubt I can understand the question.

—SA

You need to […] verbs, otherwise no one will be able to […] your questions. If some or all of the verbs are missing from your post, it cannot […] a well-formed question.
To […] about verbs, please […] this article: http://en.wikipedia.org/wiki/Verb[^].

However, even with proper use verbs, I doubt I can understand the question.

[EDIT]

Please see: http://msdn.microsoft.com/en-us/library/777e5ebh.aspx[^].

—SA
 
Share this answer
 
v4
Comments
Anderso0on 18-Mar-13 17:37pm    
i need to do two processes in a certain database if any on of them completely processing and another process not completely processing then stop all processing process,with a certain condition two processes must be located in different scope
Sergey Alexandrovich Kryukov 18-Mar-13 17:41pm    
Do you know such thing as transactions?
—SA
Anderso0on 18-Mar-13 17:43pm    
yes . but i thank transaction must be in one scope , not in different scope
Sergey Alexandrovich Kryukov 18-Mar-13 17:52pm    
Why? Same database server or not?
—SA
Anderso0on 18-Mar-13 17:52pm    
yes same database
Example on how to use transactions in c#

C#
using (SqlConnection Conn = new SqlConnection(_ConnectionString))
{
    try
    {
        Conn.Open();
        SqlTransaction Trans = Conn.BeginTransaction();

        try 
        {
            using (SqlCommand Com = new SqlCommand(ComText, Conn))
            {
                /* DB work */
            }
        }
        catch (Exception TransEx)
        {
            Trans.Rollback();
            return -1;
        }
    }
    catch (Exception Ex)
    {
        return -1;
    }
}
 
Share this answer
 
Comments
Anderso0on 18-Mar-13 17:40pm    
i can not do transaction in my situation cause the two process in different scope

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900