Update/Delete+Rollback in Dataset

Jun 16 2006 3:16 AM

//------------------------------------------------------------------------

string conn_str="Provider=MSDAORA.1;User ID=navuser2;Data Source=orcl;Password=navuser2";

 

OleDbConnection conn=new OleDbConnection(conn_str);

 

conn.Open();

 

OleDbCommand cmd = new OleDbCommand();

 

 cmd.CommandText = "select * from test";

 

cmd.Connection = conn;

 

OleDbDataAdapter adap=new OleDbDataAdapter(cmd);

 

DataSet dtset=new DataSet();

 

adap.Fill(dtset,"test");

 

string ins= "insert into TEST values(30,'900')";

 

DataTable tab1;

 

tab1=dtset.Tables["test"];

 

DataRow r1;

 

r1=tab1.NewRow();

 

adap.InsertCommand=new OleDbCommand(ins,conn);

 

tab1.Rows.Add(r1);

 

adap.Update(dtset,"test");

 

conn.Close();

 

//------------------------------------------------------------------------

Queries:

1.The above code is working fine for insert statements. How to use the above code in case of update/delete transaction? Especially when we are trying to update/delete multiple rows?

2. How to rollback transactions in dataset, in the above code???

3.When a new row is inserted (in above code), How to retrieve individual column values of newly added row.

tab1.Rows.Add(r1);

 

                  MessageBox.Show(r1[0].ToString());

 

               adap.Update(dtset,"test");

The message box simply displays empty window. How to get 30???