Beispiel #1
0
 /// <summary>
 /// 執行 SQL Insert, Update, Delete 指令
 /// </summary>
 public string NonQuery(string[] sqlcmds)
 {
     using (var trans = conn.BeginTransaction())
     {
         OleDbCommand cmd = new OleDbCommand();
         cmd.Transaction = trans;
         try
         {
             foreach (string sql in sqlcmds)
             {
                 if (!string.IsNullOrWhiteSpace(sql))
                 {
                     cmd.Connection  = conn;
                     cmd.CommandText = sql;
                     cmd.ExecuteNonQuery();
                 }
             }
             trans.Commit();
         }
         catch (Exception e)
         {
             FileRW.Write(true, Environment.CurrentDirectory + @"\NxESL_Log.txt", $"\r\n{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} : NonQuery Array Error.");
             trans.Rollback();
             return(e.Message);
         }
     }
     return("OK");
 }
Beispiel #2
0
 /// <summary>
 /// 執行 SQL Insert, Update, Delete 指令
 /// </summary>
 public string NonQuery(string sqlcmd)
 {
     try
     {
         using (OleDbCommand cmd = new OleDbCommand(sqlcmd, conn))
         {
             //cmd.CommandText = sqlcmd;
             cmd.ExecuteNonQuery();
             return("OK");
         }
     }
     catch
     {
         FileRW.Write(true, Environment.CurrentDirectory + @"\NxESL_Log.txt", $"\r\n{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} : NonQuery Error : {sqlcmd}");
         return("FAIL");
     }
 }
Beispiel #3
0
 /// <summary>
 /// 執行 SQL Insert, Update, Delete 指令
 /// </summary>
 public string NonQuery(string sqlcmd)
 {
     try
     {
         db.BeginTrans();
         //db.Execute(sqlcmd, DAO.RecordsetOptionEnum.dbDenyWrite);
         db.Execute(sqlcmd);
         db.CommitTrans();
         return("Succeed");
     }
     catch (Exception e)
     {
         db.Rollback();
         Debug.WriteLine(e.Message);
         FileRW.Write(true, Environment.CurrentDirectory + @"\NxESL_Log.txt", $"\r\n{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} : NonQuery Error : {sqlcmd}");
         return("Failed");
     }
 }