我有以下代码
using (OracleConnection srcConn = new OracleConnection())
using (OracleConnection destConn = new OracleConnection())
{
srcConn.ConnectionString = AppInfo.SrcConnStr;
srcConn.Open();
destConn.ConnectionString = AppInfo.DestConnStr;
destConn.Open();
using (OracleCommand destCmd = new OracleCommand("ALTER SESSION SET NLS_DATE_FORMAT = 'yyyy-mm-dd hh24:mi:ss'", destConn))
using (OracleCommand srcCmd = new OracleCommand("ALTER SESSION SET NLS_DATE_FORMAT = 'yyyy-mm-dd hh24:mi:ss'", srcConn))
{
// Non-query
srcCmd.ExecuteNonQuery();
destCmd.ExecuteNonQuery();
if (Timing) { ut.TimeIt(stopwatch, "Get Connection and Command"); }
srcCmd.CommandTimeout = 0;
destCmd.CommandTimeout = 0;
srcCmd.CommandText = "select * from table_name";
rd = srcCmd.ExecuteReader();
rd.FetchSize = rd.RowSize * AppInfo.BatchSize; }
OracleBulkCopy copy = new OracleBulkCopy(destConn);
copy.DestinationTableName = DestTable;
copy.BatchSize = AppInfo.BatchSize;
copy.NotifyAfter = AppInfo.BatchSize;
copy.OracleRowsCopied += new OracleRowsCopiedEventHandler(OnOracleRowsCopied);
copy.BulkCopyTimeout = AppInfo.CommandTimeOut;
copy.WriteToServer(rd);
}
}
什么时候复制.WriteToServer(rd);它给出了以下错误
System.ArgumentException was caught
Message='0' is not a valid value for 'Interval'. 'Interval' must be greater than 0.
Source=System
StackTrace:
at System.Timers.Timer.set_Interval(Double value)
at Oracle.DataAccess.Client.OracleBulkCopy.PerformBulkCopy()
at Oracle.DataAccess.Client.OracleBulkCopy.WriteDataSourceToServer()
at Oracle.DataAccess.Client.OracleBulkCopy.WriteToServer(IDataReader reader)
我的问题是,我该如何解决?
感谢任何帮助。
答案 0 :(得分:1)
问题可能是将CommandTimeout
设置为零。尝试一个合理的数字。我认为这是在几秒钟内指定的。