2007年7月27日 星期五

web.config 加解密

aspnet_regiis -pe "connectionStrings" -app "/WebSite3" -prov "DataProtectionConfigurationProvider" 好方便,這樣就加密了,不用寫程式 另外,-pd 是解密。解密時不用指定 provider aspnet_regiis -pd "connectionStrings" -app "/WebSite3"

2007年7月23日 星期一

MSDTC 設定

每次使用 TransactionScope ,再使用two face commit 時,常常遇到 MSDTC 設定不正確的問題。 今天看到 http://darkthread.blogspot.com/2006/11/kb-net-20-transactionscope.html 這裡的講解,實在太好了。 忍不住記下來 這個也很重要 http://darkthread.blogspot.com/2006/03/msdtc-on-windows-2003-sp1.html

2007年7月20日 星期五

partition by field order by field

存進資料庫時,之前為了弄出序號般的東西,通常會使用 identity 的欄位。 這是直接寫入資料庫的。通常結合 primary key ,於設計時期就規劃好這樣的欄位。 但,有時,常常,需要在UI顯示給使用者的序號,是不用寫入資料庫的。 如 訂單主檔 訂單編號 (primary key) 客戶編號 建立日期 訂單明細檔 訂單編號 產品名稱 數量 序號 (該訂單明細的明細流水號,由1開始) 像這樣的序號欄號,是有規則的,不必寫到資料庫。 以前在UI要呈現這樣的序號,可以使用UI的技巧。有時需要多一點的運算。 現在,SQL Server 2005 提供了這樣的語法層級上的支援 如 select m.BillNo, d.ProductName, d.Qty1, d.UnitQty, d.UnitPrice, NetAmount, row_number() over (partition by d.billNo order by d.billNo) as rowNum from Einvoice.dbo.invoice m inner join Einvoice.dbo.invoiceDetail d on m.BillNo = d.billNo

2007年7月16日 星期一

Sys.argumentOUtOfRangeException Value must be an integer

當我使用AJAX Toolkit 的 calendarExtender 時,發生了一個JScript錯誤 Sys.argumentOUtOfRangeException Value must be an integer Parameter anme:x Actual value was NaN 完全不知道是怎麼回事。 爬了 google,找到了原因。原來我使用了 frameset,其中的 frameborder 的值,"1", "0", "Yes", "No" 都是合法的值。 但 AJAX ToolKit 卻只認得 "1", "0" 改了之後就OK 了

2007年7月12日 星期四

'~/Root/GotoSite.aspx?site=SCIS&winType=2&url=http://www.google.com.tw' is not a valid virtual path.

寫 custom site map provider 時,發生了這樣的問題

'~/Root/GotoSite.aspx?site=SCIS&winType=2&url=http://www.google.com.tw' is not a valid virtual path.

耶?為什麼? 原來,原因指定SiteMapNode的Url 時,指定的值中有 Colon (:) Asterisk (*) 有這兩個字,就會被認為不合法。 微軟有沒有解呢?有的,見http://support.microsoft.com/kb/932552/en-us?spid=8940&sid=global

要裝hotfix哦!真是麻煩

2007年7月11日 星期三

Security Exception

今天跑之前寫好的程式,跑到一半,出現下面的錯誤訊息 Security Exception Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's 原因出在asp.net 要寫event log 時,無法寫入。因權限的問題。 最後,執行 regedit, 修改HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog 的權限,讓aspnet 可以完全控制該 registry 以及其下所有的 registry。 這個 registry path 不好記,寫在blog 備忘一下。 大功告成。不過這樣一來,aspnet 帳號就可能破壞我網頁伺服器的 event log 了,,有沒有比較好的方式呢?

2007年7月10日 星期二

無法解析equal to 動作的定序衝突

今天同事問了一個問題。

Declare @tblCUSTADR table
        (
                [CUST_ID] [char] (6) NOT NULL ,
                [Seq] [char] (1) COLLATE Chinese_Taiwan_Stroke_CI_AS NOT NULL,         
                [Sale_ADR] [nvarchar](60) COLLATE Chinese_Taiwan_Stroke_CI_AS NOT NULL          
        )

insert into @tblCUSTADR(CUST_ID, Seq, Sale_ADR)
                VALUES('A19834', '4', N'台北縣新莊市新泰路號-新杏店')

select t.* from customerAddress address
inner join @tblCUSTADR t on address.SubSeq = t.Seq
inner join Customer on t.CUST_ID = Customer.Cust_ID

結果出現了下面的錯誤訊息。
Msg 446, Level 16, State 9, Line 16
無法解析equal to 動作的定序衝突。

真是受不了,第一次碰到定序的問題。
解法如下:

select * from customerAddress address
inner join @tblCUSTADR t on  address.SubSeq COLLATE Chinese_Taiwan_Stroke_CI_AS = t.Seq COLLATE Chinese_Taiwan_Stroke_CI_AS
inner join Customer on t.CUST_ID = Customer.Cust_ID
COLLATE Chinese_Taiwan_Stroke_CI_AS

2007年7月2日 星期一

Publish a web application in vs2005 sp1

when i publish a web application, some file will change. What kind of rule it obey? I found that : when publishing an web application, all files newer than target file will be copied and overwrite the target files, even the web.config file. So, if web want publish a web application to prodution envirment, ALWAYS remeber to backup all the old files, especially the config files.

Share with Facebook