A Place for C Sharpers/.Netters

I Will do coding till last moment of life-Kiran Patil

Archive for February, 2009

Add More than one file Associations to a ClickOnce Application

Posted by kiranpatils on February 27, 2009

Challenge:

One of my friend has one windows application and when he publish it using Clickonce it should be mapped with his custom file extension. For example “.JPG” and “.PNG” files should be mapped with his application called “MyPaint.exe”.

We found it that how to do it for one extension as shown in great post :

http://blogs.msdn.com/mwade/archive/2008/01/30/how-to-add-file-associations-to-a-clickonce-application.aspx

But no information provided here for how to do it for multiple file extension..hooh it took us half of the day to do it..Here is the way…

Solution:

1. Follow the steps given in Above post. Test it for one extension if it works for it then go to step 2.

[NOTE: you can open app.manifest under properties->App.manifest.dll double click it.] It will open .manifest in XML editor.

2.Here for one extension code we have added is as shown below:

<fileAssociation xmlns=”urn:schemas-microsoft-com:clickonce.v1″

extension=”.JPG”

description=”My PAINT”

progid=”16E5861B-EAC0-45d4-A53D-9D5962A63780″

defaultIcon=”myPaint.ico”

/>

3. NOW for adding one more extension here is the way:

<fileAssociation xmlns=”urn:schemas-microsoft-com:clickonce.v1″

extension=”.JPG

description=”My PAINT”

progid=”16E5861B-EAC0-45d4-A53D-9D5962A63780

defaultIcon=”myPaint.ico”

/>

<fileAssociation xmlns=”urn:schemas-microsoft-com:clickonce.v1″

extension=”.PNG

description=”My PAINT”

progid=”2601E048-C585-4bcf-8673-3A29C51D69B4

defaultIcon=”myPaint.ico”

/>

NOTE: Your both Program ID should be different!!

That’s it.

Hope it helps you kick off your project on its Release date:)

If it helped you say Thank to My friend who has introduced a nice problem to me..

Link which has given us a Kick : http://msdn.microsoft.com/en-us/library/bb892924.aspx

Sample code can be downloaded from here

Posted in Windows Forms | Leave a Comment »

Checking Execution Time of Stored Procedure

Posted by kiranpatils on February 27, 2009

Hi All…I was invisible since so long..:)…But was too busy with my stuff so can’t post anything here…But today I learnt something new which I would like to share with you all…

Challenge:

I have written one Stored Procedure with 958 Lines..which deletes data from around >70 tables. [Ooh..]. But when I was executing it I was eager to check its execution time. And I found it..So here is the way to check execution time of your stored procedure.

Solution:

DECLARE @startproc DATETIME
DECLARE @endproc DATETIME
DECLARE @time INTEGER 

SELECT @startproc = getdate()  --take start time 

--execute sp

EXEC <YOUR SP NAME> <PARAMETERS> 

SELECT @endproc = getdate()  --take end time 

SELECT @time = DATEDIFF(millisecond, @startproc, @endproc)  --take difference in milliseconds.

PRINT str(@time) + ' Milliseconds.'

I think the way which I did is self explanatory.

The main function which I would like to elaborate further is DATADIFF : To get difference between two dates:

Here i have used millisecond as an argument you can put DAY,MONTH YEAR etc. [Beware!!! If your SP Is taking DAY/MONTH/YEAR to run then you need to think for that SP...:) Just kidding].

Here is the Link for more arguments of DATEDIFF function :http://msdn.microsoft.com/en-us/library/ms189794.aspx

Posted in SQL SERVER 2005 | Leave a Comment »