1
Answer

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

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.....
Answers (1)
0
Vishal Gilbile

Vishal Gilbile

NA 13.9k 2.9m 11y
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.