精選文章

bcp大量匯出與匯入資料庫資料方法

--匯出-- bcp "select * from [資料庫名稱].[dbo].[資料表名稱]" queryout 匯出檔案名稱.txt -w -U "使用者帳號" -P "使用者密碼" " ...

2018年12月13日 星期四

更新URL但不刷新頁面

問題:
"更新URL但不刷新頁面"
說明:
pushState() 的基本參數是:
window.history.pushState(state, title, url);

解決方法:
方法
"window.history.pushState(null, null, "/profile/");"

2018年12月12日 星期三

當匯出的excel格式為3.705E+11格式時

問題:
"當匯出的excel格式為3.705E+11,調整可顯示完整"

解決方法:
方法
    
buttons: [
       {extend: 'excelHtml5',
        filename: 'my_file_name',
        title: null,
        exportOptions: {
            format: {
                     body: function (data, row, column, node ) {
                                return column === 2 ? "\0" + data : data;
                                }
              }
           }
      }
]

2018年12月7日 星期五

如何取得 web.config 裡的 httpRuntime 資訊

問題:
如何取得 web.config 裡的 httpRuntime 資訊
說明:
maxRequestLength設定上傳檔案大小(單位是KB)
解決方法:
HttpRuntimeSection section = (HttpRuntimeSection)ConfigurationManager.GetSection("system.web/httpRuntime");

2018年12月3日 星期一

SQL Update Join

說明:
"SQL Update Join" 方法:
UPDATE Table_A
SET Table_A 欄位 = 值
From Table_A a
Left Join Table_B b on a.欄位 =b.欄位
WHERE 條件

2018年11月27日 星期二

上傳檔案容量限制

方法
 (':file').change(function () {  //選取類型為file且值發生改變的
    var file = this.files[0];    //定義file=發生改的file
    size = file.size;            //size=檔案大小
    if (file.size > 3145728) {   //假如檔案大小超過300KB (300000/1024)
        swal('檔案大小上限3MB!!');  //顯示警告!!
        $(this).val('');         //將檔案欄設為空白
    }

計算所有file容量大小
 $(':file').change(function () {  
            var sizeTotal = 0;
            $(':file').each(function (index) {
                //console.log(index + ": " + $(this).attr("id"));
                var file = this.files[0];
                var size = 0;
                if (this.files.length) {
                    size = file.size;
                    sizeTotal =sizeTotal+ file.size;
                }
                //console.log(size);
            });
            //console.log(sizeTotal);
            if (sizeTotal > 10485760) {   
                swal({
                    type: 'warning',
                    text: '所有上傳檔案加總限制10MB'
                })
                $(this).val('')
            };         

swal 為sweetalert2套件
https://sweetalert2.github.io/

2018年11月9日 星期五

razor在onclick里輸出內容包含換行符號造成異常

問題:
"razor在onclick里輸出內容包含換行符號造成語法異常"
解決方法:
方法1
<a onclick="showRemark('@(!string.IsNullOrEmpty(item.Comment) ? item.Comment.Replace("\r\n", " ") : item.Comment)','@item.CommentLastUpdate.ToString("dd-MMM-yyyy",ci)')">Detail</a>

2018年10月24日 星期三

bootstrap點彈跳視窗時,會出現element.style{padding-right:17px} 問題

問題:
bootstrap點彈跳視窗時,會出現element.style{padding-right:17px} 使整個頁面右邊會越來越往左偏移
說明:
遇到的專案是有使用sweetalert,所以使用方法5的方法有自訂了一下, 不然也可以參考該網址

https://stackoverflow.com/questions/32862394/bootstrap-modals-keep-adding-padding-right-to-body-after-closed


https://forums.oscommerce.com/topic/412058-modal-destination-and-modal-within-modal/

解決方法:
方法1
body {
padding-right: 0 !important;
overflow-y: scroll!important;
}

方法2
body,body.swal2-shown,body.modal-open {
overflow:inherit;
padding-right:inherit !important;
}

方法3
$(document.body).on('hide.bs.modal,hidden.bs.modal', function () {
$('body').css('padding-right', '0');
});

方法4
('.modal').on('hide.bs.modal', function (e) {
e.stopPropagation();
$('body').css('padding-right', '');
});

方法5
body, body.swal2-shown, body.modal-open {
padding-right: 0 !important;
overflow-y: scroll !important;
}