2009年12月7日 星期一

SQL 語法如何做到小計與合計之範例

select (case when grouping(ename)=1 then '合計' when grouping(name)=1 then '' else ename end) as ename,(case when grouping(ename)=1 then '' when grouping(name)=1 then '小計' else name end) as name,count(*) as cnt from student group by ename,name with rollup

2009年10月23日 星期五

ViewState, Session, Application 傻傻分不清楚?

ViewState
1.存在畫面中的內容,會送到Client端
畫面送出與postBack的過程都會傳送
用越多,畫面傳輸量越大
2.影響單一畫面
3.單一畫面當網址不變時活著
網址改變(例如a.aspx?i=1變成a.aspx?i=2)就消滅

Session與Application
1.都存活在Server上(記憶體中)
2.Session影響單一連線
Application影響所有連到該Web應用程式的連線(所有人都會讀到共同的資料)
3.Session會在無反應之後SessionTimeOut時間到的時候消滅
Application會在該Web應用程式Process停止後消滅

2009年8月20日 星期四

解決在 windows 64bit 版本下無法使用OWC

1. 修改應用程式集區設定,將啟用32位元應用程式設為true
2. 開啟 C:\Windows\System32\inetsrv\config\applicationHost.config 找到 add name="PasswordExpiryModule" image="C:\Windows\system32\RpcProxy\RpcProxy.dll" 並修改為 add name="PasswordExpiryModule" image="C:\Windows\system32\RpcProxy\RpcProxy.dll" preCondition="bitness64"

2009年3月25日 星期三

dropdownlist 連動注意事項

dropdownlist 若同時使用靜態資料及動態聯繫
例如新增功能列出可選擇清單並增加 "請選擇"
且會因其他 dropdownlist 連動而重新bind data
則必須於 databinding 事件清除既有資料並加入靜態資料, 如下面範例

DropDownListCourseRegion.Items.Clear();
DropDownListCourseRegion.Items.Insert(0, new ListItem("請選擇", "-1"));

若僅於設計階段加入靜態資料
則於連動過程會保留原本資料再加入新的資料
造成多餘的資料留在清單中
主要原因是為了保留靜態資料而把 appenddatabounditems 設為 true
使得相依 dropdownlist 改變選取項目時把連動dropdownlist既有清單內容當做靜態資料不予清除
造成連動 dropdownlist rebind 時保留既有資料又加上新的資料

2009年2月9日 星期一

visual studio 2003 轉換到 2008 一些問題

1. Microsoft.Web.UI.WebControls.TreeView 運作不正確
請用 System.Web.UI.WebControls.TreeView 取代

visual studio debug 網路磁碟網站 出現錯誤訊息

1. 不支援在 Windows XP 平台的 UNC 共用上裝載... 因為已經到達網路 BIOS 命令限制...

用戶端上: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanworkstation\parameters
增加 REG_DWORD 項目: MaxCmds 並設定其值>=50

伺服端上:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters
增加 REG_DWORD 項目: MaxMpxCt 並設定其值>=50


2. ASP.NET runtime error: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

Start > Control Panel > Administrative Tools > Microsoft .NET Framework 2.0 Configuration. After it fully loads (sometimes takes a bit), fully expand My Computer in the navigation tree and click Runtime Security Policy. In the right hand pane, choose Adjust Zone Security. Leave the default option (Make changes to this computer) and hit next. Choose Local Intranet and change the trust level to Full Trust.



以上設定完畢後必須重新啟動作業系統才會生效

2009年2月6日 星期五

visual studio 系統若使用到水晶報表時如何發佈到其他平台?

安裝visual studio 2008 時若同時安裝crystal report
則會將crystal report runtime 安裝程式放在底下的路徑
c:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages\CrystalReports10_5\
選擇正確的檔案安裝在發佈平台上即可

2009年1月21日 星期三

ASP.NET 實作 AD 登入驗證

1.修改web.config 加入

<connectionStrings>
<add name="ADConnectionString"
connectionString="LDAP://Lifeacademy.org/DC=Lifeacademy,DC=org"/>
</connectionStrings>

<system.web>
<membership defaultProvider="MyADMembershipProvider">
<providers>
<add
name="MyADMembershipProvider"
type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName="ADConnectionString"
connectionUsername="laaspnet"
connectionPassword="laaspnet000"
attributeMapUsername="SAMAccountName"
/>
</providers>
</membership>


2.參考加入System.DirectoryServices

3.網頁加入login控制項

2009年1月9日 星期五

Entity Framework 建立新物件並儲存後馬上取得關聯資料

使用 CreateProxy 建立物件,不要直接 new var newmodel = _contextXXX.CreateProxy<yyy>(); ... _contextXXX.yyy.Add(newmodel); await _contextXXX.SaveC...