咨詢電話: 400-898-5151
        料中心 DOWNLOAD
        在組態王中如何實現在access數據庫中始終保存一個月的歷史數據,自動刪除一個月之前的歷史數據的功能?
        時間:2018-08-17 瀏覽次數:2454

        實現過程如下:

        1)請將控制面板中的區域設置日期改為yyyy-mm-dd格式;

        2)在組態王應用程序命令語言啟動時輸入如下腳本語言:

        SQLConnect( DeviceID, "dsn=歷史;uid=;pwd="); 

        long month=\本站點$月-1; 

        long year=\本站點$年; 

        long day=\本站點$日; 

        string date1; 

        if(month==0) 

        {

        month=12; 

        year=\本站點$年-1;} 

        date1= StrFromInt( year, 10 ); 

        date1=date1+"-"; 

        date1 = date1 + StrFromInt( month, 10 ); 

        date1 = date1 + "-" + StrFromInt( day, 10); 

        string whereexpr="日期={#’"+date1+"’}"; 

        SQLDelete( DeviceID, "A", whereexpr); 

        if (\本站點$月==4||\本站點$月==6||\本站點$月==9||\本站點$月==11) 

        {

          if (\本站點$日==30) 

        day=31; 

        date1= StrFromInt( year, 10 ); 

        date1=date1+"-"; 

        date1 = date1 + StrFromInt( month, 10 ); 

        date1 = date1 + "-" + StrFromInt( day, 10);

        whereexpr="日期={#’"+date1+"’}"; 

        SQLDelete( DeviceID, "A", whereexpr); 

        }

        }


        -->