数据库操作异常写入日志文件
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 }
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 }
相关文章推荐
- Sql Server实用操作-无数据库日志文件恢复数据库两种方法
- STS创建Spring Boot项目实战(Rest接口、数据库、用户认证、分布式Token JWT、Redis操作、日志和统一异常处理)
- Spring-Boot--日志操作【全局异常捕获消息处理☞日志控制台输出+日志文件记录】
- 给数据库某些特定表的写操作记录到文件的日志功能的静态类
- 通过python操作GeoLite2-City.mmdb库将nginx日志访问IP转换为城市写入数据库
- 多进程同时操作数据库并同时写日志文件,方法中带参数传递
- 利用POI对MS Excel进行读写(可以设置写入文件的样式),利用tm-extractor对Word进行读取操作并将信息用(log4j)日志信息显示出
- 设置Log4j 的properties文件,将日志写入数据库
- 怎样操作数据库的Blob字段将文件写入数据库!!!
- 《WebApi》----将异常堆栈信息写入日志文件
- 小白学Linux之C语言中如何爬出异常或将异常写入日志文件中
- asp.net中使用Global.asax文件中添加应用出错代码,写入系统日志文件或数据库
- [转贴]Sql Server实用操作-无数据库日志文件恢复数据库两种方法
- centos6.5 salt的操作日志写入数据库
- Spring aop实现用户操作日志写入数据库
- (OAF)jdeveloper集成log4j并将日志输出到指定文件并写入数据库
- SQL SERVER 2005 镜像数据库截断并收缩日志文件的思路和操作
- logback系统异常日志写入文件
- sql2008 r2 数据库日志文件已满,无法进行其他操作
- Spring-Boot--日志操作【全局异常捕获消息处理☞日志控制台输出+日志文件记录】