Click here to Skip to main content
16,011,930 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually what i wan to do is ?
i wan to insert into database with transaction that is also used in getting the datatable back?
i.e i want to save data into Table Contact
I used

C#
sqltransaction tans=null;
open.con() //to opendatabase connection
begintransaction();
_db.save('i',"2",trans);
_db.GetArea("China",trans);
public datatable GetArea(string name,sqltransaction trans)
{
  string query ="select * from Area where AreaName='"+name+"'";
  datatable dt = new datatable()
 dt= con.open.getdatatable(query,trans);
}
public datatable getdatatable(string SelectQuery,sqltransaction)
{
    SqlDataAdapter da = new SqlDataAdapter(SelectQuery, Class1.Connection);
    System.Data.DataTable dt = new System.Data.DataTable();
    //'hbug'
    try
    {
        da.Fill(dt);
        return dt;
    }
    catch
    {
        throw;
    }
}

how can i use that transaction in this getdatatable?
Posted
Updated 24-Jul-12 1:06am
v2

1 solution

Your question not too clear. Look here on how to implement transactions in code using ADO.NET:
MSDN: Local Transactions[^]
Using Transactions in ADO.NET[^]
 
Share this answer
 

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