Parcourir la source

添加Sql出错日志输出,便于排查问题。

jianfeng1.wang il y a 2 ans
Parent
commit
69728c5d5f
1 fichiers modifiés avec 9 ajouts et 3 suppressions
  1. 9 3
      FactoryTool_CShare/Database/DbHelper.cs

+ 9 - 3
FactoryTool_CShare/Database/DbHelper.cs

@@ -1,7 +1,9 @@
-using System;
+using SXLibrary;
+using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Data;
 using System.Data;
 using System.Data.SqlClient;
 using System.Data.SqlClient;
+using System.Diagnostics;
 using System.Linq;
 using System.Linq;
 using System.Text;
 using System.Text;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
@@ -28,9 +30,9 @@ namespace MOKA_Factory_Tools.Database
                     connection.Close();
                     connection.Close();
                     return true;
                     return true;
                 }
                 }
-                catch
+                catch(Exception e)
                 {
                 {
-
+                    Log.WriteErrorLog(string.Format("{0}", e.Message));
                 }
                 }
             }
             }
 
 
@@ -870,6 +872,7 @@ namespace MOKA_Factory_Tools.Database
                     }
                     }
                     catch (System.Data.SqlClient.SqlException e)
                     catch (System.Data.SqlClient.SqlException e)
                     {
                     {
+                        Log.WriteErrorLog(string.Format("{0}-{1}", strSQL, e.Message));
                         throw e;
                         throw e;
                     }
                     }
                 }
                 }
@@ -897,6 +900,7 @@ namespace MOKA_Factory_Tools.Database
                 catch (System.Data.SqlClient.SqlException e)
                 catch (System.Data.SqlClient.SqlException e)
                 {
                 {
                     connection.Close();
                     connection.Close();
+                    Log.WriteErrorLog(string.Format("{0}.{1}", strSQL, e.Message));
                     throw e;
                     throw e;
                 }
                 }
             }
             }
@@ -924,6 +928,7 @@ namespace MOKA_Factory_Tools.Database
                     }
                     }
                     catch (System.Data.SqlClient.SqlException e)
                     catch (System.Data.SqlClient.SqlException e)
                     {
                     {
+                        Log.WriteErrorLog(string.Format("{0}.{1}", strSQL, e.Message));
                         throw e;
                         throw e;
                     }
                     }
                 }
                 }
@@ -951,6 +956,7 @@ namespace MOKA_Factory_Tools.Database
                 }
                 }
                 catch (System.Data.SqlClient.SqlException e)
                 catch (System.Data.SqlClient.SqlException e)
                 {
                 {
+                    Log.WriteErrorLog(string.Format("{0}.{1}", strSQL, e.Message));
                     throw e;
                     throw e;
                 }
                 }
             }
             }