Why Response.Redirect throws exception in try catch block ?

If you use the Response.Redirect, or Server.Transfer method, a ThreadAbortException exception occurs. When you use try-catch statement then you will find it.

This problem occurs in above methods because both methods call Response.End internally. The Response.End method ends the execution and redirect it to the Application_EndRequest event. So the line of code that follows Response.End is not executed.

If you want to solve this problem then use Response.Redirect with endresponse parameter like Response.Redirect (“pagename”, false). so it suppress the internal call to Response.End method and for Server.Transfer, use Server.Execute method instead of Server.Transfer method.

Record count of all table

Simple sql query to count record of all tables.

SELECT 
     TBL.TABLE_NAME AS [TABLE NAME], MAX(SI.ROWS) AS [RECORD COUNT]
FROM
     SYSINDEXES SI, INFORMATION_SCHEMA.TABLES TBL
WHERE
     TBL.TABLE_NAME = OBJECT_NAME(SI.ID) AND TBL.TABLE_TYPE = 'BASE TABLE'
GROUP BY 
     TBL.TABLE_SCHEMA, TBL.TABLE_NAME

QueryString in JavaScript

JScript function to retrive QueryString from URL. Function is written for One Parameter.

function retVal(qstr)
{
/*
take last location of ?
find first location of qstr +2
retrieve value before next &
*/

var qURL = new String(window.location);
var qMark= qURL.lastIndexOf('?');
var Lenqstr = qstr.length;
//retrieve location of qstr

var Start = qURL.indexOf('?' + qstr + '=')

if (Start==-1)
{
Start = qURL.indexOf('&' + qstr + '=')

if (Start==-1)
{
return 0; //not found
}
}

Start = Start + Lenqstr + 2;
var Temp= qURL.indexOf('&',Start); //next pair start

if (Temp ==-1)
{
Temp=qURL.length;
}
return qURL.slice(Start,Temp );
qURL=null;//set String null
}

//For Finding param name
//var iURL = new String(window.location);
//var iMark = iURL.lastIndexOf('?');
//var iEqual = iURL.lastIndexOf('=');
//var str = iURL.slice(iMark+1,iEqual);

alert(retVal('QParam'));

To Call this page use PageName.aspx?QParam=tValue