The thing is this, Currently I'm developing some sort of application where I have to upload data from an excel sheet, and the save it into a database table (oracle). I managed to accomplish this process by the OracleDataAdapter class
_adapter = new OracleDataAdapter(query, _conn);
_adapter.Update(_dataTable);
However it takes a lot of time to save the data loaded in the gridView, like 12 min for 100000 registries. Then I tried the OracleBulkCopy
which indeed does the work in about 10 to 15 seconds, but the problem its that it does not respect the primary key from the database. I tried everything but it doesn't respect the constraint.
I also tried to make the insert method by myself by doing something like this:
OracleCommand cmdInsert = new OracleCommand();
cmdInsert.CommandText = query;
cmdInsert.Connection = DataAccess._conn;
OracleParameter id_Filtro = new OracleParameter();
cmdInsert.Parameters.Add(id_Filtro);
foreach (DataRow r in _table.Rows)
{
id_Filtro.DbType = DbType.Int32;
id_Filtro.Value = Convert.ToInt32(r["ID_FILTRO"].ToString());
id_Filtro.ParameterName = "id_Filtro ";
cmdInsert.ExecuteNonQuery();
}
I did the same for every parameter, but also takes ages to insert all the data, about 25 min or so. I wonder if there is some better way to do the process. If anyone could help me I would be really grateful. I can update the post to clarify any inquiry, please notice that I'm not a database or programmer expert.