【日 志】
/// <summary> /// 记录执行sql时的错误日志 /// <para>cmdTxt 执行的sql</para> /// <para>inputParams 传入的Hashtable参数</para> /// </summary> private static void LogLastError(string cmdTxt, Hashtable inputParams) { try { StringBuilder sb = new StringBuilder(); sb.AppendLine("OperateRecord 操作数据库发生错误 : \r\n====================插如sql或存储过程名称"); sb.AppendFormat("{0}", cmdTxt).AppendLine(); sb.AppendLine("====================参数如下"); if (inputParams != null && inputParams.Count > 0) foreach (DictionaryEntry entry in inputParams) sb.AppendFormat("参数名称:{0} 参数值:{1}", entry.Key, entry.Value).AppendLine(); LogHelper.Instance.WriteError(sb.ToString()); } catch (Exception ex) { string path = string.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, "记录执行sql时的错误日志 发生异常.txt"); string text = string.Format("\r\n {0} {1} \r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), ex.ToString()); System.IO.File.AppendAllText(path, text); } }