Tuesday, June 28, 2005

Avoiding "Case When" From your TSQL in MS-SQLServer

Today I was working on a query with a conditional construct where i had to use CASE WHEN. But a "Case when" will be evaluted for each record.
Keeping this thought was looking for a new logic. At last i arrived that

SELECT FirstName, LastName, Status
FROM RequestTable
Inner join
Select -1 as Appr , 'New' as Status
Select 0, 'Created'
Select 1, 'Accepted'
Select 2, 'Rejected'
) T

On IsNull(Cast(Approved as smallint),-1) = Appr

Wednesday, June 08, 2005

How to display form only once in MDI application in .Net

You can create a static variable in the form to keep the reference of the form and a static Showform method to invoke the form.

Class Form1
static Form1 frm;

static ShowForm()
if (frm==null) frm=new Form1;

Now from the menu click call