Error
1 executing stored procedures in. CS
2
3 try
4
5 {}
6
7 catch (Exception ex)
& nbsp;8 {
9 cm. Connection.close ();
10 Qiao. Value = "Fail";
11 publicunit.saveerror (ex,this. Context,this. Request);
12 }
14
16 Write log writing
-
-public static void Saveerror (Exception ex,httpcontext hc,httpreques T hr)
19 {
20 string temp;
21 StreamWriter SW;
23 //If there is a file
24 if (file.exists (HR). physicalapplicationpath+@ "\error.txt")
25 {
26 SW = File.appendtext (HR. physicalapplicationpath+@ "\error.txt");
27 temp = DateTime.Now.ToString () + "-------------------------------------------------- ----------------------------------\ n ";
28   temp = "error message:" + ex. Message + "\ n";
29 temp = "The name of the application or object that caused the error:" + ex. Source + "\ n";
30 temp = "Stack contents:" + ex. StackTrace + "\ n";
31 Temp + = "method that throws an exception:" + ex. TargetSite + "\ n";
32 temp = "error page" +hr. Rawurl + "\ n";
a
34 SW. WriteLine (temp);
35 SW. Close ();
36 }
37 }