C # using OracleBulkCopy



The first to use PL / SQL statements by: select * from v $ version; check out the oracle version used to get the corresponding version of Oracle.DataAccess.DLL 
I use the local version: 11.2.0.4.0 (64)

Oracle.DataAccess .DLL Download: https://www.oracle.com/database/technologies/odac-downloads.html
after download DLL directory: ODAC112040Xcopy_64bit \ odp.net20 \ odp.net \ bin \ 2.x \ Oracle.DataAccess. dll

code is as follows (rpm):

/// <summary>
/// 批量插入数据
/// </summary>
/// <param name="table">数据表</param>
/// <param name="targetTableName">数据库目标表名</param>
/// <returns></returns>
public bool ExcuteBulkData(DataTable table, string targetTableName)
{
bool result = false;
using (OracleConnection conn = new OracleConnection(connectionString))
{
using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connectionString,OracleBulkCopyOptions.Default))
{
if (table != null && table.Rows.Count > 0)
{
bulkCopy.DestinationTableName = targetTableName;
for (int i = 0; i<table.Columns.Count; i++)
{
string col = table.Columns[i].ColumnName;
bulkCopy.ColumnMappings.Add(col, col);
}
conn.Open();
bulkCopy.WriteToServer(table);
result = true;
}
}
}
return result;
}

  After the first start of the project given the information: Additional information: Could not load file or assembly "Oracle.DataAccess, Version = 2.112.4.0, Culture = neutral, PublicKeyToken = 89b483f429c47342" or one of its dependencies. Trying to load program with an incorrect format.

  To find a solution: Modify the visual studio startup solution platform: here the Any CPU instead x64, X64 does not need to add.

 

 

  Later encountered the following error: Other Information: ORA-1843: not a valid month, later found there is an incoming process corresponding to the field is not set DataTable time format. (DataTable field inside the order and format and to insert the same table

Guess you like

Origin www.cnblogs.com/XinruiIIiiiii/p/12107864.html