1 在.cs中执行存储过程
 2 
 3 try
 4 
 5 {}
 6 
 7 catch(exception ex)
 8    {
 9     cm.connection.close() ;
10     qiao.value ="fail";
11     publicunit.saveerror(ex,this.context,this.request) ;
12    }
13 
14  
15 
16 写日志的编写
17 
18 public static void saveerror(exception ex,httpcontext hc,httprequest hr)
19   {
20    string temp ;
21    streamwriter sw ;
22 
23    //如果存在文件
24    if(file.exists([email protected]"/error.txt"))
25    {
26     sw = file.appendtext([email protected]"/error.txt") ;
27     temp = datetime.now.tostring() + "------------------------------------------------------------------------------------/n";
28     temp += "错误消息:" + ex.message +"/n";
29     temp += "导致错误的应用程序或对象的名称:" + ex.source +"/n";
30     temp += "堆栈内容:" + ex.stacktrace +"/n";
31     temp += "引发异常的方法:" + ex.targetsite +"/n";
32     temp += "错误页面" +hr.rawurl + "/n/n";
33 
34     sw.writeline(temp) ;
35     sw.close() ;
36    }
37   }
38
新闻热点
疑难解答
图片精选