2011年9月27日 星期二

舊系統裡的address 轉到新的5都的 SQL

舊系統裡的address 轉到新的5都的 SQL

使用SQL更換方法,將table改成你的table名稱及address改為你的欄位名稱
由於現在起“台”要換成“臺”,所以我們先將“台”換成“臺”。
update table set address = replace(address, '台', '臺');

update table set address = replace(address, '臺北縣', '新北市');
update table set address = replace(address, '臺中縣', '臺中市');
update table set address = replace(address, '臺南縣', '臺南市');
update table set address = replace(address, '高雄縣', '高雄市');


村改為「里」:
先檢查路名有沒有村字,以免掩蓋錯誤!排除過後,再進行更換。
select address from table where `address` like '%村%' and `address` like '%新北市%';
update table set address = replace(address, '村', '里') where `address` like '%村%' and `address` like '%新北市%';
select address from table where `address` like '%村%' and `address` like '%臺中市%';
update table set address = replace(address, '村', '里') where `address` like '%村%' and `address` like '%臺中市%';
select address from table where `address` like '%村%' and `address` like '%臺南市%';
update table set address = replace(address, '村', '里') where `address` like '%村%' and `address` like '%臺南市%';
select address from table where `address` like '%村%' and `address` like '%高雄市%';
update table set address = replace(address, '村', '里') where `address` like '%村%' and `address` like '%高雄市%';


臺北縣:
update table set address = replace(address, '萬里鄉', '萬里區');
update table set address = replace(address, '金山鄉', '金山區');
update table set address = replace(address, '板橋市', '板橋區');
update table set address = replace(address, '汐止市', '汐止區');
update table set address = replace(address, '深坑鄉', '深坑區');
update table set address = replace(address, '石碇鄉', '石碇區');
update table set address = replace(address, '瑞芳鎮', '瑞芳區');
update table set address = replace(address, '平溪鄉', '平溪區');
update table set address = replace(address, '雙溪鄉', '雙溪區');
update table set address = replace(address, '貢寮鄉', '貢寮區');
update table set address = replace(address, '新店市', '新店區');
update table set address = replace(address, '坪林鄉', '坪林區');
update table set address = replace(address, '烏來鄉', '烏來區');
update table set address = replace(address, '永和市', '永和區');
update table set address = replace(address, '中和市', '中和區');
update table set address = replace(address, '土城市', '土城區');
update table set address = replace(address, '三峽鎮', '三峽區');
update table set address = replace(address, '樹林市', '樹林區');
update table set address = replace(address, '鶯歌鎮', '鶯歌區');
update table set address = replace(address, '三重市', '三重區');
update table set address = replace(address, '新莊市', '新莊區');
update table set address = replace(address, '泰山鄉', '泰山區');
update table set address = replace(address, '林口鄉', '林口區');
update table set address = replace(address, '蘆洲市', '蘆洲區');
update table set address = replace(address, '五股鄉', '五股區');
update table set address = replace(address, '八里鄉', '八里區');
update table set address = replace(address, '淡水鎮', '淡水區');
update table set address = replace(address, '三芝鄉', '三芝區');
update table set address = replace(address, '石門鄉', '石門區');


臺中縣:
update table set address = replace(address, '太平市', '太平區');
update table set address = replace(address, '大里市', '大里區');
update table set address = replace(address, '霧峰鄉', '霧峰區');
update table set address = replace(address, '烏日鄉', '烏日區');
update table set address = replace(address, '豐原市', '豐原區');
update table set address = replace(address, '后里鄉', '后里區');
update table set address = replace(address, '石岡鄉', '石岡區');
update table set address = replace(address, '東勢鎮', '東勢區');
update table set address = replace(address, '和平鄉', '和平區');
update table set address = replace(address, '新社鄉', '新社區');
update table set address = replace(address, '潭子鄉', '潭子區');
update table set address = replace(address, '大雅鄉', '大雅區');
update table set address = replace(address, '神岡鄉', '神岡區');
update table set address = replace(address, '大肚鄉', '大肚區');
update table set address = replace(address, '沙鹿鎮', '沙鹿區');
update table set address = replace(address, '龍井鄉', '龍井區');
update table set address = replace(address, '梧棲鎮', '梧棲區');
update table set address = replace(address, '清水鎮', '清水區');
update table set address = replace(address, '大甲鎮', '大甲區');
update table set address = replace(address, '外埔鄉', '外埔區');
update table set address = replace(address, '大安鄉', '大安區');


臺南縣:
update table set address = replace(address, '永康市', '永康區');
update table set address = replace(address, '歸仁鄉', '歸仁區');
update table set address = replace(address, '新化鎮', '新化區');
update table set address = replace(address, '左鎮鄉', '左鎮區');
update table set address = replace(address, '玉井鄉', '玉井區');
update table set address = replace(address, '楠西鄉', '楠西區');
update table set address = replace(address, '南化鄉', '南化區');
update table set address = replace(address, '仁德鄉', '仁德區');
update table set address = replace(address, '關廟鄉', '關廟區');
update table set address = replace(address, '龍崎鄉', '龍崎區');
update table set address = replace(address, '官田鄉', '官田區');
update table set address = replace(address, '麻豆鎮', '麻豆區');
update table set address = replace(address, '佳里鎮', '佳里區');
update table set address = replace(address, '西港鄉', '西港區');
update table set address = replace(address, '七股鄉', '七股區');
update table set address = replace(address, '將軍鄉', '將軍區');
update table set address = replace(address, '學甲鎮', '學甲區');
update table set address = replace(address, '北門鄉', '北門區');
update table set address = replace(address, '新營市', '新營區');
update table set address = replace(address, '後壁鄉', '後壁區');
update table set address = replace(address, '白河鎮', '白河區');
update table set address = replace(address, '東山鄉', '東山區');
update table set address = replace(address, '六甲鄉', '六甲區');
update table set address = replace(address, '下營鄉', '下營區');
update table set address = replace(address, '柳營鄉', '柳營區');
update table set address = replace(address, '鹽水鎮', '鹽水區');
update table set address = replace(address, '善化鎮', '善化區');
update table set address = replace(address, '大內鄉', '大內區');
update table set address = replace(address, '山上鄉', '山上區');
update table set address = replace(address, '新市鄉', '新市區');
update table set address = replace(address, '安定鄉', '安定區');


高雄縣:
update table set address = replace(address, '仁武鄉', '仁武區');
update table set address = replace(address, '大社鄉', '大社區');
update table set address = replace(address, '岡山鎮', '岡山區');
update table set address = replace(address, '路竹鄉', '路竹區');
update table set address = replace(address, '阿蓮鄉', '阿蓮區');
update table set address = replace(address, '田寮鄉', '田寮區');
update table set address = replace(address, '燕巢鄉', '燕巢區');
update table set address = replace(address, '橋頭鄉', '橋頭區');
update table set address = replace(address, '梓官鄉', '梓官區');
update table set address = replace(address, '彌陀鄉', '彌陀區');
update table set address = replace(address, '永安鄉', '永安區');
update table set address = replace(address, '湖內鄉', '湖內區');
update table set address = replace(address, '鳳山市', '鳳山區');
update table set address = replace(address, '大寮鄉', '大寮區');
update table set address = replace(address, '林園鄉', '林園區');
update table set address = replace(address, '鳥松鄉', '鳥松區');
update table set address = replace(address, '大樹鄉', '大樹區');
update table set address = replace(address, '旗山鎮', '旗山區');
update table set address = replace(address, '美濃鎮', '美濃區');
update table set address = replace(address, '六龜鄉', '六龜區');
update table set address = replace(address, '內門鄉', '內門區');
update table set address = replace(address, '杉林鄉', '杉林區');
update table set address = replace(address, '甲仙鄉', '甲仙區');
update table set address = replace(address, '桃源鄉', '桃源區');
update table set address = replace(address, '茂林鄉', '茂林區');
update table set address = replace(address, '茄萣鄉', '茄萣區');
update table set address = replace(address, '那瑪夏鄉', '那瑪夏區');


資料來源: http://www.aoron.com/%E6%96%B0%E4%BA%94%E9%83%BD%E5%9C%B0%E5%9D%80%E5%90%8D%E7%A8%B1%E6%9B%B4%E6%8F%9B%E5%88%97%E8%A1%A8.php

2011年9月26日 星期一

CDONTS.NewMail 改寫成 CDO.Message 的建議寫法

CDONTS.NewMail 改寫成 CDO.Message 的建議寫法:
把舊的 Send_Email副程式改寫成 Object, 透過 Object 讀取 SMTP 相關設定來寄信.

建議增加 ContentType 屬性到 Attachment Tag 中

建議增加 ContentType 屬性到 Attachment Tag 中, 方便 xsl 進行套版的判斷.




我寫了一個小小小的副程式, 依檔名來傳回 MIME Type.

2011年9月19日 星期一

備份M$ SQL Server 的database 請使用 back/restore, 不要直接copy mdf 檔案

備份M$ SQL Server 的database 請使用 back/restore, 不要直接copy mdf 檔案, 不然就會有版本的問題, 如下圖所示:




檢查目前正在使用的 Database 的版本的 SQL:
select DATABASEPROPERTYEX('master','Version')


我執行出來的結果:

(說明: 版本是 611)


常見的情況:程式設計師的開發環境,安裝的是 SQL Server 2008 R2 express 版本,但是客戶端伺服器機器是:SQL Server 2008 版本。

聽說: 在新版本 SQL Server 2008 R2 上的資料庫,是沒辦法直接使用附加、還原的方式,將資料庫搬移到舊版本的 SQL Server 2008上。

2011年9月14日 星期三

[IIS].64bit主機32bit元件安裝的建議

---------------------------------------------------------------------
1.關於 IIS網站應用程式集區(application pool) 所使用的帳號, 建議前台 使用 webUser 帳號, 後台使用 webAdmin 帳號, 如果怕麻煩, 就通通使用 webAdmin.

附註: 實體的 .asp 檔, 要允許 webAdmin 有 access 權限.


---------------------------------------------------------------------
2.關於 Com+ 元件的建立, 建立元件時, 建議使用帳號 webAdmin 來當執行時的帳號, 並設定 webAdmin 到 CreatorOwner 裡.

附註: 在元件的這個步驟, 要把 "強制此應用程式的存取檢查" 的勾勾拿掉.


---------------------------------------------------------------------
3.加好的 Com+ 裡, 如果使用 32bit 的元件,
在元件裡按 "內容" -- "進階" -- "允許IIS內建內容" 打勾

附註1: 加進來的元件, 記得把方法(method) 的 folder 展開來看看, 如果展開沒有東西的話, 就是加入失敗, 請重頭再來一次.

附註2: 實體的 .dll 檔, 要允許 webAdmin 有 access 權限.

2011年9月6日 星期二

副程式裡的data input 建議相同的資料, 只要一個進入點

最近有同事在修改資安的白箱檢測, 我看到修改後的程式碼, 覺得關於副程式裡的data input 建議相同的資料, 只要一個進入點似乎會比較好.


相同的資料 request 了 3次 與 request 1次相比, request 1次的好處是, 對該相同資料的前置處理, 只需做一次, 下圖是 request 了 3次 的寫法.


附註: 當然, 世事無絕對, 有些複雜的情況下, 重覆去 request 是有可能會讓程式變的比較簡單.



建議的寫法: 就是一開始先把 request 的結果放到一個變數裡.
如果, 程式愈寫愈大, 資料在副程式間的傳遞用 object 來傳, 也不錯, 像是 XML 的 Dom Object 或 Recordset Object, 或是 user 自定的 object 或是 json.

2011年9月5日 星期一

javascript childNodes length 在不同瀏覽器間的差異

前陣子, 遇到一個奇怪的情況,
同一行指令, 在 IE 與非IE 執行的結果不同,
與大家一起分享...



■■━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■ 先來看看用 ie 看 xml 的資料如下:
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━



■■━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■ 用 chrome 看 xml 的資料如下:
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━


說明: span 裡, 放一個 span, span 的下一層, 再放一個 span, 3層式的 span.



■■━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■ 有問題的程式碼, 只有下面這一行, 猜猜看 alert 出來的數字應該是多少?
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━




■■━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■ ie 的答案是: 1
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━



■■━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■ google chrome 的答案是: 3
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━





■■━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
■ 解決辦法: 使用 getRealChild function 即可取得"一致" 的length
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
var myRealChilds = getRealChild(myNodeObj);
//alert(myRealChilds.length);

function getRealChild(elem){
var realChild = [];
for(var i = 0;i < elem.childNodes.length; i++){
if(elem.childNodes[i].nodeType == 1){
realChild.push(elem.childNodes[i]);
}
}
return realChild;
}

2011年9月2日 星期五

連續2個節點做np redirect 的判斷


情況, 要在1個 folder 上點一下後, 連到下一個 folder 裡的第1筆資料


解法: 就是 np 之後, 判斷要連的節點的主題單元是使用 "網頁模組" 就再做1次np 即可.

手動設定 facebook 的 iframe 頁面的語系

多丟一個 locale=en_US 即可.

語系的設定, 有助於您在開發英文介面的 UI, 在 facebook 的世界裡, 通常 中文字的 font size = 14 , 英文語系 font size = 12. font size 的差異, 參考看看下圖.


Facebook 留言板