2008/09/03

SQL Server 在 charindex 全形及半形判斷上的問題

在預設的情況下,中文的SQL Server的定序設定為Chinese_Taiwan_Stroke_CI_AS, 會把全形及半形視為相同字元,這會影響到我們在SUBSTRING及CARINDEX上的判斷,如果字串內同時有全形及半形的符號,SQL Server皆會把它視為相同的符號...
如果我們在不能改資料庫設定的情況下,如何讓全形及半形的符號有所區隔呢?

直接用以下例子說明:



declare @txt nvarchar(200)
select @txt = '華,碩平,台【重裝火炮】DVD燒錄遊戲電腦'

select charindex(',', @txt)
select charindex(',', @txt COLLATE Chinese_Taiwan_Stroke_CI_AS_WS)


結果:

-----------
2

(1 個資料列受到影響)


-----------
5

(1 個資料列受到影響)

update:
如何執行區分全型/半型的sql select?
select * from aaa(nolock) where aaa_name like '%?%' COLLATE Chinese_Taiwan_Stroke_CI_AS_WS
-- COLLATE Chinese_Taiwan_Stroke_CI_AS_WS放在like的後面



重點就在於預設的COLLATE是Chinese_Taiwan_Stroke_CI_AS,改成Chinese_Taiwan_Stroke_CI_AS_WS就OK了,詳細請參考:

1.Windows Collation Name (Transact-SQL)
2.COLLATE (Transact-SQL)
3.Collation Precedence
4.定序對話方塊 (Visual Database Tools)

PHILIPS移動世界 2.5吋 250G SATA行動硬碟-聯強貨

2008/08/28

Application, Page and Control events in ASP.NET v2.0 - Jeff's Junk

Application, Page and Control events in ASP.NET v2.0 - Jeff's Junk

Application, Page and Control events in ASP.NET v2.0 發生順序的列表

Application: BeginRequest
Application: PreAuthenticateRequest
Application: AuthenticateRequest
Application: PostAuthenticateRequest
Application: PreAuthorizeRequest
Application: AuthorizeRequest
Application: PostAuthorizeRequest
Application: PreResolveRequestCache
Application: ResolveRequestCache
Application: PostResolveRequestCache
Application: PreMapRequestHandler
Page: Construct
Application: PostMapRequestHandler
Application: PreAcquireRequestState
Application: AcquireRequestState
Application: PostAcquireRequestState
Application: PreRequestHandlerExecute
Page: AddParsedSubObject
Page: CreateControlCollection
Page: AddedControl
Page: AddParsedSubObject
Page: AddedControl
Page: ResolveAdapter
Page: DeterminePostBackMode
Page: PreInit
Control: ResolveAdapter
Control: Init
Control: TrackViewState
Page: Init
Page: TrackViewState
Page: InitComplete
Page: LoadPageStateFromPersistenceMedium
Control: LoadViewState
Page: EnsureChildControls
Page: CreateChildControls
Page: PreLoad
Page: Load
Control: DataBind
Control: Load
Page: EnsureChildControls
Page: LoadComplete
Page: EnsureChildControls
Page: PreRender
Control: EnsureChildControls
Control: PreRender
Page: PreRenderComplete
Page: SaveViewState
Control: SaveViewState
Page: SaveViewState
Control: SaveViewState
Page: SavePageStateToPersistenceMedium
Page: SaveStateComplete
Page: CreateHtmlTextWriter
Page: RenderControl
Page: Render
Page: RenderChildren
Control: RenderControl
Page: VerifyRenderingInServerForm
Page: CreateHtmlTextWriter
Control: Unload
Control: Dispose
Page: Unload
Page: Dispose
Application: PostRequestHandlerExecute
Application: PreReleaseRequestState
Application: ReleaseRequestState
Application: PostReleaseRequestState
Application: PreUpdateRequestCache
Application: UpdateRequestCache
Application: PostUpdateRequestCache
Application: EndRequest
Application: PreSendRequestHeaders
Application: PreSendRequestContent

來源 : Jeff's Junk

ConSonic 8GB 玩美時尚碟

2008/08/05

PowerSheel ADO.NET SQLAdapter Timeout Error

Ben.geek.nz » ADO.NET SQLAdapter Timeout Error

在使用PowerShell寫批次時,用到SqlDataAdapter的Fill時,常會遇到timeout的情況,如:


$ds= new-object "System.Data.DataSet" "ds"
$adapter = new-object "System.Data.SqlClient.SqlDataAdapter"
$adapter.SelectCommand = new-object "System.Data.SqlClient.SqlCommand" ($sql, $conn);

if ($adapter2.Fill($dstoprank) -gt 0) #在這裡會出現timeout error


解決方案:


myAdapter.SelectCommand.CommandTimeout = int.MaxValue; //(.Net)

or


$adapter.SelectCommand.CommandTimeout = 2147483647; # int.MaxValue (PowerShell)

2008/05/14

jquery 的$(document).ready 在 firefox 有 onclick 的問題

最近在使用jquery 1.2.3 版本,發生了奇怪的問題….

通常我們在送出一個form表,會使用一個function檢查form的內容,

例如以下為一個CheckForm的Function



<script language="javascript" type="text/javascript">

Function CheckForm(thisForm){

$(document).ready(function(){
If (thisForm.text1.value != “") {
thisFrom.submit();
}
}
}

</script>


若使用



<a href="javascript:CheckForm(this.form);">submit button</a>


完全沒問題,在IE及FireFox都正常!
但若使用button



<input type="button" name="btnSubmit" value="submit button" onclick="javascript:CheckForm(this.form);">


在FireFox則會無法送出form,原因出在於CheckForm()裡的$(document).ready()沒有反應…跑到這裡就停住了…

查了許久,仍查不出原因,初步推斷可能是jquery 1.2.3在firebox的一個onclick的bug,因為在jquery 1.1.1時是沒有問題的。

現在的解決方式是,在

<script language="javascript" type="text/javascript"></script>
裡,
加一段:



$(document).ready(function(){

});


如此一來正常work了…只是沒找出真正的原因,要花點時間去找找官方的討論區。

2008/04/16

javascript : How to call opener function & set opener element ?

Opener window : openerwindow.html



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>Opener window</title>
</head>
<script type="text/javascript" language="javascript">
function OpenNewWindow()
{
window.open("newwindow.html");
}
function CallMe()
{
alert("hello!");
}
</script>
<body>
<form action="#" method="post" name="form1">
<a id="clickme" href="#" onclick="OpenNewWindow();">Click me !</a>
<br />
<input name="textbox1" type="text" value="" />
</form>
</body>
</html>



New window : newwindow.html



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>New window</title>
</head>
<script type="text/javascript" language="javascript">
function CallOpenerFunction()
{
if (!window.opener.closed)
{
// call opener function
window.opener.CallMe();
}
}
function SetOpenerElement()
{
if (!window.opener.closed)
{
// set opener element
var tf = opener.document.forms[0];
tf.textbox1.value = "hi!";
}
}
</script>
<body>
<a href="#" onclick="CallOpenerFunction();">call opener function</a>
<br />
<a href="#" onclick="SetOpenerElement();">set opener element</a>
</body>
</html>

軟體工程的重要的指標