您的位置:首页 > 数据库

数据库操作异常写入日志文件

2007-01-20 17:03 633 查看
1
2public class ErrorOperate:System.Web.UI.Page,System.IDisposable
3
44
53 public void InsRow(string[] astrColName,string[] astrColValue)
54 {
55 string strSQL = "";
56 string strColName = " ";
57 string strColValue = " ";
58 try
59 {
60 //形成insert语句
61 for(int i=0;i<astrColName.Length;i++)
62 {
63 strColName = strColName + astrColName[i] + ",";
64 strColValue = strColValue + "'" + astrColValue[i] + "'" + ",";
65 }
66
67 //去掉最右边的","
68 strColName = strColName.Substring(0,strColName.Length-1);
69 strColValue = strColValue.Substring(0,strColValue.Length-1);
70
71 //增加上右括号"(" 与 左括号")"
72 strColName = "(" + strColName + ")";
73 strColValue = "(" + strColValue + ")";
74
75 //形成最终的SQL
76 strSQL="insert into " + strTabName + strColName + " values " + strColValue;
77 ExecuteSQL(strSQL);
78 }
79 catch(Exception er)
80 {
81
82 ErrorOperate error=new ErrorOperate();
83 error.writeLog(er.Message+"\r\n"+"错误地址:"+er.StackTrace+"\r\n"+"错误语句:"+strSQL);
84
85 throw new System.ObjectDisposedException( er.Message);
86 }
87 finally
88 {
89
90 }
91
92 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐