I’m using a DataAdapter and DataTable to edit/add data in a Oracle db table, using ODP.NET provider.
DataSet ds = new DataSet("report");
DataTable dt = new DataTable("report");
adptr = new OracleDataAdapter();
string myCmd = "select * from report";
OracleCommand _cmd = new OracleCommand(myCmd, myDbConnection);
adptr.SelectCommand = _cmd;
adptr.Fill(dt);
ds.Tables.Add(dt);
After this i alter the data in the data table, by binding it to a grid and editing it and save like this :
OracleCommandBuilder _cmdBld = new OracleCommandBuilder(adptr);
adptr.Update(ds, "report");
Everything great by now, it works as it’s supposed to, every modification gets commited to the DB.
But my problem is the following – when i get data from more than one table.
like this :
string myCmd =
"select r.id, u.username, r.creation_date, r.owner
from report r inner join users u on r.user_id == u.id";
I know I could write the DataAdapter‘s update command manually (DataAdapter.UpdateCommand) , before saving, but i’m not sure how. Can you give me some directions?
Thanks!
Check out the example provided in MSDN. I guess OracleDataAdapter works with same logic.
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldataadapter.updatecommand.aspx
Here is the update command generation section from specified link