– try catch finally notes

March 27, 2014

The code inside a finally block will get executed regardless of whether or not there is an exception.

Exception handling in C#. In the below code


//Throwing Error
//Getting Caught
int x =3;

int x = 5 ;

In Try after throwing an Error which is caught in Catch ,After that Finall Block Executes with Assignment of x=3. and after that next line x=5 is also executed.Program not getting terminated..What might be the reason ?

SqlServer notes : Inbuilt reports provided by Sqlserver itself

March 13, 2014

In Object Explorer


right click on server name and select Reports->Standard Reports->

Performance -Top Queries by Average CPU Time

SQL SERVER – Comma Separated Values (CSV) from Table Column

January 22, 2014

Is there a way to convert a single column record set such as


into ’1,2,3′ string in SQL Server?

1st way :


CREATE FUNCTION [dbo].[fn_MyFunction]


    DECLARE @Delimiter CHAR(2) 
    SET @Delimiter = ', '

    SELECT @str = COALESCE(@str + @Delimiter,'') + AColumn
    FROM dbo.myTable



2nd Way :

select stuff( (select ',' + YourColumn
               from YourTable
               for xml path('')), 1, 1, '')
3rd Way :

Select @Out = COALESCE(@Out + ', ', '') + [YourColumn] from YourTable

print @Out

4th way Best one :

(SELECT ',' + s.Name
FROM HumanResources.Shift s
FOR XML PATH('')),2,200000) AS CSV


MS word tips

January 16, 2014

To change uppercase lowercase


Shift + F3 file upload control error

January 4, 2014

HTTP Error 404.13 – Not Found : The request filtering module is configured to deny a request that exceeds the request content length – See more at:



<requestLimits maxAllowedContentLength=”2048000000″></requestLimits>


I was developing an application that allows user to upload files to the server using the <asp:FileUpload/> control. In order to make sure that users can upload large files, I configured the web.config as follows to allow larger files to be uploaded (The default setting is 4 MB):
<httpRuntime maxRequestLength="512000"/><!--To allow up to 500MB-->
While testing the file upload functionality from within the visual studio development server (Right clicking on the aspx file and selecting browse), I found it working quite fine. But surprisingly, after hosting the web site onto IIS (IIS 7), I found the file uploading functionality was no longer working, and, it was broken while trying to upload large files (I was trying with a file over 40MB in size). Following is the screen shot of the error message that I got:

Figure : The error message from IIS while trying to upload a large file
The error page also suggested me to do the followings:
“Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting in the applicationhost.config or web.config file.”
So, as suggested, I did the following configuration in the web.config of my web site(By setting maxAllowedContentLength value in Bytes):
  <modules runAllManagedModulesForAllRequests="true"/>
      <requestLimits maxAllowedContentLength="512000"></requestLimits>
Guess what, it didn’t work out! After modification when I tried to upload the file again, the same problem occured again. What happened?
According to the error message, the web.config or applicationhost.config should be configured according to the above suggestion. Modifying web.config didn’t work out. So, the applicationhost.config could be modified to see what happens.

Wait a minute! the applicationhost.config is the configuration file of IIS (IIS7.0 or heigher). Does that mean IIS has a Request size validation?

Yes it has. Until IIS 7.0 there was no Request size validation, but since IIS 7.0, the Request length is verified by IIS first, before deliverying the Request to
So, to be true, it doesn’t really make any sense to increase the maxAllowedContentLength value in web.config. The Request dies even before reaching the So, whatever is to be configured, it has to happen at IIS.
Well, as I figured out, there are two ways you can configure this value in IIS:
1. Configuring the applicationhost.config
Open the %WINDIR%\System32\inetsrv\config\applicationHist.config in editor and specify the following configuration within the security/requestFiltering section(By setting maxAllowedContentLength value in Bytes):
      <requestLimits maxAllowedContentLength="512000000"></requestLimits>
Modifying the above configuration worked for me in one PC (Running Windows 7+IIS 7.0), but, didn’t work on another one (Running Windows Vista + IIS 7.0). After configuring the applicationHost.config file, I tried to upload the large file and the same error message was appearing again. I don’t know why, but, if you have the same experience, applying the following approach (Configuring via IISManager) would definitely work. 
2. Configuring via IISManager
Open the IIS Manager and select the site or application you need to configure in the left panel
Select “Features View” and double click on the “Request Filtering” icon.
Figure : Request Filtering
Note :
If you can’t find the “Request Filtering”icon, you need to install the IIS Administration Pack from this link : This is a lightweight installation which shouldn’t take too much time on a decent internet speed.
Double clicking on the “Request Filtering”icon will bring up the Request filtering configuration window. Right click on the window and select the “Edit Feature Settings” option:
Figure : Edit Feature Settings option in IIS
Finally, specify the Maximum allowable content length (In Byte) in the following window and click “OK” to save:
Figure : Specifying Maximum allowable content length in Bytes
This worked perfect for me and I was able to upload the large file now without any problem. Hope, this will work for you too :)

- See more at:

Sqlserver notes

December 23, 2013

how to assign return value of stored procedure to a new variable
@In INT,

SELECT @Out = ‘Test’

If you are unable to change the stored procedure, another solution would be to define a temporary table, and insert the results into that


OutputValue VARCHAR(100)
INSERT INTO #tmpTable (OutputValue)
EXEC dbo.sp_name 9999, 99989999, ‘A’, ‘S’, null

@Output = OutputValue

DROP TABLE #tmpTable


sql server find string in another string

DECLARE @document varchar(64);

SELECT @document = ‘Reflectors are vital safety’ +
‘ components of your bicycle.’;
SELECT CHARINDEX(‘bicycle’, @document);

Result : 48

Install a .NET windows service without InstallUtil.exe

December 17, 2013

when i was in client place I got a problem

I need to install a windows service using installutil.exe but there is no visual studio command prompt tool.


sc create ServiceName binPath= “c:\windowservice1\windowservice1.exe”

here ServiceName is userdefined name it can be anything

When creating the service there is a space between the = and “

ie after binPath= provide a space

Deleting a windows service from command prompt

sc delete ServiceName

Install window service without using installutil

Article is about to install window service without using InstallUtil utility.
Windows XP or Later has command line utility called sc . (This utility talks with service controller and with services from command line).
SC is a window base utility. AS explain in article sc does not required ProjectInstaller.

1. Start service using sc
sc start ServiceName

2. Stop serivce
sc stop ServiceName

3. Delete window service
sc delete servicename
Note : During delete call if service is in running state then service is delete when nexttime service is stop or PC restart.

4. Create window service
sc create ServiceName binpath= “c:\windowservice1\windowservice1.exe”

Apart from above many option available . For that just go to command prompt and type sc create /?

For example configure service running account.

sc create servicename binpath= “c:\windowservice1\windowservice1.exe” obj= administratorpassword= pass





watching files in folder console application c#

How to Open Windows Task Scheduler (control panel->administrative tools->task schedulter in windows7)

debug windows service c# visual studio 2008

from vs command prompt
C:\Windows\system32>installutil -u E:\Projects\HimalayaPhase2\Phase2\AutoRecManP


Get every new post delivered to your Inbox.