I need a very simple way to insert data from DataTable object to Oracle table. I'm using c#.
I have the data in my datatable.I just need to now insert that data into a oracle table.
I know that some like this needs to be done
foreach (datatable.row) insert into table values()
This is what I tried but it did not at all work.
dt1= dt.Clone();
foreach (DataRow dr in dt.Rows) {
dt1.ImportRow(dr);
}
for (int i = 0; i < dt1.Rows.Count; i++) {
Console.WriteLine("---in------");
OracleCommand ocmd = new OracleCommand(
"insert into t_test_position (position_id,position_desc) values ('"
+ dt1.Rows[i]["position_id"].ToString() + "','"
+ dt1.Rows[i]["position_desc"].ToString() + "')", oraconn);
ocmd.ExecuteNonQuery();
}
It could be a temporary table oracle. I'm having exactly the same problem right now and the best solution I found is to change the temporary table to normal table.