Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Updating a table on DB considering changes on a grid in Csharp

1011121May 27 2013
I'm filling a Data Grid in C# (WinForms) via a System.Data.DataTable. DataTable is filled from a DB table via ODP.

I have a data navigator in Data Grid for updating, deleting and inserting rows.

I want to use DataTable to commit all changes made in Data Grid to the database.

I have to use OracleDataAdapter but I couldn't figure out how to achieve this.

What kind of a CommandText should I use to achieve all three commands (update, delete, insert)?

The code below didn't work (maybe because CommandText I inserted is not appropriate)

public void ExecuteNonQuery(string commandText, OracleCommand oracleCommand, CommandType commandType, DataTable dataTable)
{
oracleCommand.CommandText = commandText;
oracleCommand.CommandType = commandType;

try
{
oracleCommand.Connection = m_Connection;
OracleDataAdapter oracleDataAdapter = new OracleDataAdapter(oracleCommand);
oracleDataAdapter.Update(dataTable);
}
catch (Exception)
{
LoggerTrace.Instance.Write(TraceEventType.Error, LoggerTrace.LoggerTraceSource.DatabaseManagerError, "Query could not be executed!");
throw;
}
}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 24 2013
Added on May 27 2013
0 comments
312 views