当前位置: 首页>>代码示例>>C#>>正文


C# DBConnection.execDataTable方法代码示例

本文整理汇总了C#中DBConnection.execDataTable方法的典型用法代码示例。如果您正苦于以下问题:C# DBConnection.execDataTable方法的具体用法?C# DBConnection.execDataTable怎么用?C# DBConnection.execDataTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBConnection的用法示例。


在下文中一共展示了DBConnection.execDataTable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckEEP_ExecutingServiceStateTable

 private bool CheckEEP_ExecutingServiceStateTable(string sProjectID)
 {
     bool blExistence = false;
     DBConnection cDBConnection;
     try
     {
         cDBConnection = new DBConnection();
         DataTable dtt = new DataTable();
         DataRow[] dtwSelection;
         string cmdSQL = "select name from SysObjects order by name";
         dtt = cDBConnection.execDataTable(cmdSQL, gsEEPDB);
         dtwSelection = dtt.Select("name = 'EEP_ExecutingServiceState'");
         switch (dtwSelection.Length)
         {
             case 1: // have being the table.
                 blExistence = true;
                 gLogger.Trace("已經有EEP_ExecutingServiceState的Table");
                 break;
             case 0://Create a new table
                 cmdSQL = "CREATE TABLE dbo.EEP_ExecutingServiceState (ProjectID NVARCHAR (50) NOT NULL, ServiceName NVARCHAR (50) NOT NULL, RecTime DATETIME NOT NULL, AlarmIntervalMinute INT NOT NULL, CONSTRAINT PK_EEP_ExecutingServiceState PRIMARY KEY (ProjectID, ServiceName));";
                 //cmdSQL = string.Format("CREATE TABLE [dbo].[RMC_HistoryData_{0}_{1}]([EquipmentID] [nvarchar](50) NULL, [PointID] [nvarchar](50) NULL, [PointValue] [nvarchar](50) NULL, [RecTime] [datetime] NULL) ON [PRIMARY]", sProjectID, DateTime.Now.ToString("yyyyMM"));
                 cDBConnection.execNonQuery(cmdSQL, gsEEPDB);
                 blExistence = true;
                 gLogger.Trace("產生新的EEP_ExecutingServiceState的Table");
                 break;
         }
     }
     catch (Exception ex)
     {
         gLogger.ErrorException("UpdateServiceTime.CheckEEP_ExecutingServiceStateTable", ex);
     }
     return blExistence;
 }
开发者ID:FTCEEP,项目名称:CGUST,代码行数:33,代码来源:UpdateServiceTime.cs

示例2: Update_Time

        private string gsProjectID = ConfigurationManager.AppSettings.Get("ProjectID"); //從AppConfig讀取「ProjectID」參數

        #endregion Fields

        #region Methods

        /// <summary>
        /// 紀錄WindowServic運作時間
        /// 用來判斷WindowService是否有正常作動
        /// </summary>
        public void Update_Time()
        {
            DBConnection cDBConnection;
            bool blFlag;
            string cmdSQL = string.Empty;
            string sServiceName = gsProjectID + ".ModbusTCP.Adapter(" + gsIP + ":" + gsPort + ")";
            try
            {
                cDBConnection = new DBConnection();
                blFlag = false;
                blFlag = CheckEEP_ExecutingServiceStateTable(gsProjectID);
                if (blFlag == false)
                {
                    gLogger.Error("產生EEP_ExecutingServiceState Table失敗");
                }
                cmdSQL = string.Format("SELECT * FROM EEP_ExecutingServiceState WHERE ProjectID = '{0}' AND ServiceName = '{1}'", gsProjectID, sServiceName);
                DataTable dttExecutingServiceState = cDBConnection.execDataTable(cmdSQL, gsEEPDB);
                if (dttExecutingServiceState.Rows.Count > 0)
                {
                    cmdSQL = string.Format("UPDATE EEP_ExecutingServiceState SET RecTime = '{2}', AlarmIntervalSecond = '{3}' WHERE ProjectID = '{0}' AND ServiceName = '{1}'", gsProjectID, sServiceName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), dttExecutingServiceState.Rows[0]["AlarmIntervalSecond"].ToString());
                    cDBConnection.execNonQuery(cmdSQL, gsEEPDB);
                    gLogger.Trace("更新WindowService監控時間成功");
                }
                else
                {
                    cmdSQL = string.Format("INSERT INTO EEP_ExecutingServiceState (ProjectID, ServiceName, RecTime, AlarmIntervalSecond) VALUES ('{0}', '{1}', '{2}', '{3}')", gsProjectID, sServiceName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), giSystemRunTimeRecord);
                    cDBConnection.execNonQuery(cmdSQL, gsEEPDB);
                }
            }
            catch (Exception ex)
            {
                gLogger.ErrorException("UpdateServiceTime.Update_Time", ex);
            }
        }
开发者ID:FTCEEP,项目名称:CGUST,代码行数:44,代码来源:UpdateServiceTime.cs


注:本文中的DBConnection.execDataTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。