Skip to content

How to use transaction in asp.net give me a step by step ex.

fresher developer

Asked Mar 12, 2013, 1:16 AM EDT1 answer
Share
LinkedInX
hello.. sir
 i don,t know about the store procedure and transaction  i am always use Query in my project but that time i have need the transaction/store procedure used for updating two table record plse give me step by step example ....plz i am fresher.....

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Vishal Gilbile
    0
    Hello Friend,
                   you can execute procedure in the following way, well i'm using oracle database but in your case you can go with Sql. Only ADO.Net Classes will change
    for e.g.
    OracleConnection will  become SqlConnection
    OracleTransaction will become SqlTransaction etc.


    Following is the code for the same.

      OracleConnection con = new OracleConnection("your connection string");
                con.Open();
                OracleTransaction trans = con.BeginTransaction();
                OracleCommand cmd = new OracleCommand("procecureName", con);
                cmd.CommandType = CommandType.StoredProcedure;
                OracleParameter para = new OracleParameter();
                para.ParameterName = "v_docdata";
                para.OracleType = OracleType.Blob;
                para.Value = rawBytes;
                para.Size = rawBytes.Length;
                cmd.Parameters.Add(para);
                cmd.Transaction = trans;
                cmd.ExecuteNonQuery();
                trans = null;
                con.Close();

    Hope that Solves your problem.

    With Regards,
    Vishal Gilbile.
    0