Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Updating a table on Oracle DB considering changes on a grid in C#

$
0
0

I'm filling a Data Grid in C# (WinForms) via a System.Data.DataTableDataTable 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 (updatedelete,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;
        }
}


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>