2013年12月24日 星期二

[除錯] 無法繫結至 DataSource 上的屬性或欄位 或 無法清除這個清單

原因:
Error:無法繫結至 DataSource 上的屬性或欄位
            bs_tblT內外銷統計附檔.DataMember = null;
            bs_tblT內外銷統計附檔.DataSource = null;

Error:無法清除這個清單
            bs_tblT內外銷統計附檔.Clear();

解決:
用bindingsource isbindingsuspended


            foreach (Control item in this.tableLayoutPanel1.Controls)
            {
                item.DataBindings.Clear();
            }
            lbl_檔案名稱.DataBindings.Clear();  
            //忘記把這個ctl給DataBindings.Clear()...
            //因為此ctl是屬於flowLayoutPanel2
            //而flowLayoutPanel2是屬於tableLayoutPanel1
            //所以此ctl我需要另外將其DataBindings.Clear()
            //而不是寫在foreach裡面...那邊只會找到flowLayoutPanel2

參考:
我的表單本來可以開啟的,因為我把access資料庫裡的欄位user改成user_1
[除錯] System.InvalidCastException: System.Data.DataViewManagerListItemTypeDescriptor
如何在dataTable更新完成後,才讓綁定的dataGridView 做更新?

2013年12月13日 星期五

[除錯] entilb DAAB [The type Database cannot be constructed. You must configure the container to supply this value]

 問題:
The type Database cannot be constructed. You must configure the container to supply this value.

Activation error occured while trying to get instance of type Database, key "ExpSys.Properties.Settings.ConnSqlStr"

解決:
組件[YC_ExpSys.exe]
設定檔[YC_ExpSys.exe.config]

當組件在組件[DayCensorWinApp.exe]上運行時
設定檔[DayCensorWinApp.exe.config]需新增設定檔[YC_ExpSys.exe.config]的設定資料
因為是由[DayCensorWinApp.exe]開啟[YC_ExpSys.exe]
而其設定檔是讀[DayCensorWinApp.exe.config]

環境:
entlib 5.0
vs2010
.net 3.5 sp1

參考:
The type Database cannot be constructed. You must configure the container to supply this value.
The type Database cannot be constructed. You must configure the container to supply this value (EntLib 5 + ODP.NET)
Activation error occured while trying to get instance of type Database, key "cnx"
Activation error occured while trying to get instance of type Database, key “” <— blank
Enterprise Library 5 with ODP.NET

2013年12月12日 星期四

[SQL] 去除欄位中(或左右兩邊)的空白

Q:
在SELECT COUNT(*)時都無法正確取得數量...
故猜測是多了空白...

A:
某A在插入CustomerOrderNo時, 右邊多了N個空白...

Solution Code:
SELECT a.CustomerOrderNo,a.CustomerOrderDate,a.CustomerID,a.CompanyName,(SELECT count(*) FROM [tblT出貨統計資料表] WHERE CustomerOrderNo = replace(a.CustomerOrderNo,' ','')) as Qty
FROM [tblT訂單統計資料表] as a LEFT JOIN [tblODeliveryOrder] as b on a.CustomerOrderNo = b.CustomerOrderNo WHERE b.DeliveryOrderNo = 'PO201210030';

參考:
去除MS SQL欄位中空白
sql字串去除左右空白字元
SQL Trim 函數