1 Reply Latest reply: Nov 15, 2012 11:58 AM by Mark Williams-Oracle RSS

    OracleBulkCopy problem converting System.DateTime to Date using bulkset

    974128
      Hi,

      I'm trying to perform bulk insert using OracleBulkCopy object (i'm using win64_11gR2_client).
      The obc.WriteToServer gets a DataTable as a parameter from a typed dataset.
      I get the following exception when performing obc.WriteToServer(table) :

      DML BulkSender - error inserting bulk: System.ArgumentException: Invalid parameter binding
      Parameter name: System.DateTime
      at Oracle.DataAccess.Client.OracleBulkCopy.SetColumnInfo(Type srcColType, OPOBulkCopyColCtx* pColumn)
      at Oracle.DataAccess.Client.OracleBulkCopy.ProcessSrcColumns()
      at Oracle.DataAccess.Client.OracleBulkCopy.WriteDataSourceToServer()
      at Oracle.DataAccess.Client.OracleBulkCopy.WriteToServer(DataRow[] rows)
      at DML.OracleBulkManager`1.RetryBulkCopyToDatabase(TBulkSet bulkSet, String tableName) in D:\T360\Main\Target360App\Source\DML\DML\DAL\OracleBulkManager.cs:line 221
      at DML.OracleBulkManager`1.BulkCopyToDatabase(TBulkSet bulkSet) in D:\T360\Main\Target360App\Source\DML\DML\DAL\OracleBulkManager.cs:line 75

      My code:

      using (OracleBulkCopy obc = new OracleBulkCopy(_connectionString))
      {              

      foreach (DataTable table in bulkSet.Tables)
      {
      if (table.TableName == "Activity_Flat")
      {
      LoggerMain.Instance.WriteLog(LevelType.DEBUG, "Skipping Activity_Flat");
      continue;
      }
      if (table.Rows.Count > 0)
      {
      LoggerMain.Instance.WriteLog(LevelType.DEBUG, "DML BulkSender writing to DB table", table.TableName);


      obc.DestinationTableName = table.TableName;

      try
      {
      obc.WriteToServer(table);
      }
      catch (Exception err)
      {
      LoggerMain.Instance.WriteLog(LevelType.EXCEPTION, "DML BulkSender - error writing to table ", table.TableName, ":", err);
      RetryBulkCopyToDatabase(bulkSet, table.TableName);
      }
      }
      }