<分区>
我有一个使用以下代码运行的方法:
private void WriteToDb()
{
using (SqlConnection dbConnection = new SqlConnection(_conStr))
{
dbConnection.Open();
using (SqlBulkCopy sbc = new SqlBulkCopy(_conStr))
{
sbc.DestinationTableName = "tblLog";
try
{
sbc.WriteToServer(_tblLog);
}
catch (Exception e)
{
Console.WriteLine(String.Format("{0} Error writing log info: {1} \n {3}", DateTime.Now.ToString(), e.Message, e.StackTrace));
}
}
}
_tblLog.Rows.Clear();
}
我收到来自 String.Format()
方法的异常,堆栈跟踪如下:
Unhandled Exception: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) at System.String.Format(IFormatProvider provider, String format, Object[] args) at System.String.Format(String format, Object arg0, Object arg1, Object arg2) at MyCompany.MyClient.MySoftware.Logger.WriteToDb()
我真的能看出这个错误的根源。据我所知,我没有在该方法中使用任何集合。我还不得不承认这种方法是多线程的,但我还是想不出可能的影响。
谢谢!