Archive

Archive for the ‘Uncategorized’ Category

WITH keyword in SQL Server

December 1, 2011 Leave a comment
Most people are using “WITH (NOLOCK)” instead of “ (NOLOCK)” and sometimes they asked you to put it “WITH” in front of it. But it is not necessary for the reason below
WITH is not required for 2 reasons:
1. The following table hints are allowed with and without the WITH keyword: NOLOCK, READUNCOMMITTED, UPDLOCK, REPEATABLEREAD, SERIALIZABLE, READCOMMITTED, FASTFIRSTROW, TABLOCK, TABLOCKX, PAGLOCK, ROWLOCK, NOWAIT, READPAST, XLOCK, and NOEXPAND
2. "WITH" keyword is deprecated feature in the future SQL server
Omitting the WITH keyword is a deprecated feature and will be removed in a future version of Microsoft SQL Server. Always specify WITH in new development work, and modify applications that currently omit this keyword.
Link:
http://msdn.microsoft.com/en-us/library/ms187373.aspx
Categories: Uncategorized

Delayed Script/Waiting in Javascript

November 30, 2011 Leave a comment

I was struggling in finding out of how to make a simple delegate like in AJAX request through javascript. It takes me a few days to figure this out

Basically the problems are:

-I need to execute a piece code of javascript after getting the ticket from web service function

-The webservice function might not be responding to the first request because it waits for the state of the other external component

-The webservice will give the response when the external component is ready

-The client does not know when the external component is ready, neither the web service. But it wil be ready within 1-5 minutes which again depending external component

Possible Solution:

-Using the setTimeOut(function(){acquireTicket();}, 300000) will cause the application to wait for 5 mins before calling the web service , this approach will slowing down the user experience and waste of time because the external component can be ready earlier than 5 mins

-Using the while loop is not good because it makes the browser freezing while waiting and it will wasting the processing power because of the looping

Recommended Solution:

-Recall the function by itself using setTimeout Function using parameter to indicate whether it should go out of the loop or not

-The web service will be checked for every 2 seconds to check the response from the external component. Once the external component is ready then it will move on to execute the next line of code

-

Categories: Uncategorized

Access javascript object properties with invalid character

November 17, 2011 Leave a comment

ParseJSON returning you an object from your AJAX Call, the problem that I have is my object properties has invalid character (e.g “#”)

Assuming jsonData is my variable that contains the following information

I’d like to grab the property of “#innerxml”

Normally I can do this to get the property of an object but in this case I can’t due to invalid character

(jQuery.parseJSON(jsonData)[0]).#innerxml

So How do I access an object which has properties where one of the property name is using an invalid character (e.g “#”)

I can access with the following style

(jQuery.parseJSON(jsonData)[0])['#innerxml']

Categories: Uncategorized

Cleanup File name from invalid characters

November 9, 2011 Leave a comment

I have a function that is used to save a file base on the user input (basically the user can type whichever filename and whichever path) and the code is not handling the invalid filename or path hence what it does is just throwing .NET general exception like below

To fix it I created a new function that basically get the invalid path characters and invalid filename characters from the system and remove invalid character in the input (file name). By doing this the user does not need to replace the character.

If you use Path.GetFileName it will actually remove the illegal character automatically but the way it removes the illegal character is so aggressive

e.g Path.GetFileName(“c:\workflow\Clearance:Photo ID Badge:Access abc-123.ist”) will return Access abc-123.ist

Well this problem itself will give different argument like why do we let people put the garbage character in?and why don’t we give the validation?or the other argument is “why do we need to change the input from the user without letting them knowing it?

  236    ”’ <summary>

237     ”’ this function is used to clean up invalid/illegal characters from filename and replace it with blank

238     ”’ </summary>

239     ”’ <param name=”FileName”></param>

240     ”’ <returns></returns>

241     ”’ <remarks></remarks>

242     Private Function CleanFileName(ByVal FileName As String) As String

243         Dim invalid As String = New String(Path.GetInvalidFileNameChars()) + New String(Path.GetInvalidPathChars())

244         Dim originalPath As String = FileName.Substring(0, FileName.LastIndexOf(“\”) + 1)

245         FileName = FileName.Substring(FileName.LastIndexOf(“\”))

246

247         For Each c As Char In invalid

248             FileName = FileName.Replace(c.ToString(), “”)

249         Next

250

251         ‘readd the path

252         FileName = originalPath + FileName

253

254         Return FileName

255     End Function

Categories: Uncategorized

Profiling CLR for .NET application

November 9, 2011 Leave a comment

CLR Profiler can be used to analyse how your object is allocated in memory and which object has taken the most memory. It also can be used to detect memory leak

To download CLR profiler for .NET 2.0 please visit http://www.microsoft.com/download/en/details.aspx?id=13382 , there is another version for .NET framework 1.1

-Extract the file into your desired location

-you also need to run “regsvr32 ProfilerOBJ.dll” otherwise you will get dialog message that mentioned it’s waiting for the CLR and you will not get any result

- Run the CLRProfiler.exe in Binariesx86 if your app is 32 bit and Binariesx64 if your app is 64 bit

For profiling windows app, you can do the following steps:

1. Select the exe file

2. Do stuff/interact with your application

3. Once you are finished then you can close your application or select “Kill Application”

4. Upon completion it will give you the screen below

For profiling ASP.NET app, you can do the following steps:

1. Select Profile ASP.NET from file menu

2. It will restart your IIS with the necessary trace

3. Select “Start ASP.NET”

4. Once you are finished then select “Kill ASP.NET”

5. It will restart the IIS and remove the trace added before

6. Upon completion it will give you the screen below

*You can use this for service as well –

This is the information for GC

Categories: Uncategorized

Fransiscuss.com is back

October 26, 2011 Leave a comment

After a few months, my website has been down because of someone from Tunisia was proudly hacking my website for his glory without thinking the impact to someone else. well anyway, life goes one and I forgive him regardless. I’ll start writing a few articles in the next few weeks of Message broker in SQL Server, Dependency Injection, and Thread pooling.

Categories: Uncategorized
Follow

Get every new post delivered to your Inbox.

Join 178 other followers