Friday, 20 April 2012
Tuesday, 17 April 2012
Get Querystring with Javascript...
function getUrlParams() {
var paramMap = {};
if (location.search.length == 0) {
return paramMap;
}
var parts = location.search.substring(1).split("&");
for (var i = 0; i < parts.length; i ++) {
var component = parts[i].split("=");
paramMap [decodeURIComponent(component[0])] = decodeURIComponent(component[1]);
}
return paramMap;
}
Then you could do the following to extract id from the url /hello.php?id=5&name=value
var params = getUrlParams();
var id = params['id']; // or params.id
For Reference....
Sunday, 15 April 2012
How to check session is expired or not.....
protected void Page_Load() {
if (Context.Session != null)
{
if (Session.IsNewSession)
{
string cookieHeader = Request.Headers["Cookie"];
if ((null != cookieHeader) && (cookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
Response.Redirect("sessionTimeout.htm");
}
}
} }
if (Context.Session != null)
{
if (Session.IsNewSession)
{
string cookieHeader = Request.Headers["Cookie"];
if ((null != cookieHeader) && (cookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
Response.Redirect("sessionTimeout.htm");
}
}
} }
Wednesday, 11 April 2012
How to provide IE 7.0 Compatibility viewfrom IE8.0 in .NET?
IE Compatibility View You can add the meta tag in the OnInit event of the page as shown in the below code:
protected override void OnInit(EventArgs e){ //Always do the
check before adding the meta tag if
(CheckBrowser("IE", 8)) { HtmlMeta
meta = new HtmlMeta();
meta.HttpEquiv = "X-UA-Compatible"; meta.Content = "IE=EmulateIE7"; this.Page.Header.Controls.AddAt(0, meta); }} /// <summary>/// Checks the browser./// </summary>/// <param name="browserName">Name of the browser.</param>/// <param name="browserMajorVersion">The browser major version.</param>/// <returns></returns>public static bool CheckBrowser(string browserName, int browserMajorVersion){ HttpBrowserCapabilities br = HttpContext.Current.Request.Browser; if (br.Browser.ToUpper().Equals(browserName) && (br.MajorVersion == browserMajorVersion)) return true; else return false;} |
Answered by hellosati14 |
|
Sunday, 8 April 2012
DELETE THE DUPLICATE ROWS IN EMP
DELETE THE DUPLICATE ROWS IN EMP
This query is used to delete the duplicate rows in the any table:
Before executing the query you must have the table with the name emptest the table structure is create table emptest(empno int,empName varchar(50),deptNo int ,sal money)
insert into emptest values(14,'xxx',10,10000)
insert into emptest values(13,'fsdaasf',11,20000)
insert into emptest values(10,'xcas',12,30000)
insert into emptest values(12,'d',10,40000)
insert into emptest values(11,'e',11,50000)
insert into emptest values(15,'f',12,60000)
insert into emptest values(16,'g',10,70000)
WITH Emp AS
(SELECT ROW_NUMBER ( ) OVER
( PARTITION BY empNo,empName,deptno,sal ORDER BY empNo ) AS RNUM FROM emptest )
DELETE FROM Emp WHERE RNUM > 1
Wednesday, 4 April 2012
Get All Tables Reserved And Used Sizes.....
CREATE PROC GetAllTableReservedAndUsedSizes
AS
BEGIN TRY
DECLARE @table_name VARCHAR(500) ;
DECLARE @schema_name VARCHAR(500) ;
DECLARE @tab1 TABLE
(
tablename VARCHAR(500) COLLATE database_default ,
schemaname VARCHAR(500) COLLATE database_default
) ;
DECLARE @temp_table TABLE
(
tablename SYSNAME ,
row_count INT ,
reserved VARCHAR(50) COLLATE database_default ,
data VARCHAR(50) COLLATE database_default ,
index_size VARCHAR(50) COLLATE database_default ,
unused VARCHAR(50) COLLATE database_default
) ;
INSERT INTO @tab1
SELECT t1.name ,
t2.name
FROM sys.tables t1
INNER JOIN sys.schemas t2 ON ( t1.schema_id = t2.schema_id ) ;
DECLARE c1 CURSOR FOR
SELECT t2.name + '.' + t1.name FROM sys.tables t1 INNER JOIN sys.schemas t2 ON ( t1.schema_id = t2.schema_id ) ;
OPEN c1 ;
FETCH NEXT FROM c1 INTO @table_name ;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @table_name = REPLACE(@table_name, '[', '') ;
SET @table_name = REPLACE(@table_name, ']', '') ;
-- make sure the object exists before calling sp_spacedused
IF EXISTS ( SELECT OBJECT_ID
FROM sys.objects
WHERE OBJECT_ID = OBJECT_ID(@table_name) )
BEGIN
INSERT INTO @temp_table
EXEC sp_spaceused @table_name, false ;
END
FETCH NEXT FROM c1 INTO @table_name ;
END ;
CLOSE c1 ;
DEALLOCATE c1 ;
SELECT t1.* ,
t2.schemaname
FROM @temp_table t1
INNER JOIN @tab1 t2 ON ( t1.tablename = t2.tablename )
ORDER BY schemaname ,
t1.tablename ;
END TRY
BEGIN CATCH
SELECT -100 AS l1 ,
ERROR_NUMBER() AS tablename ,
ERROR_SEVERITY() AS row_count ,
ERROR_STATE() AS reserved ,
ERROR_MESSAGE() AS data ,
1 AS index_size ,
1 AS unused ,
1 AS schemaname
END CATCH
AS
BEGIN TRY
DECLARE @table_name VARCHAR(500) ;
DECLARE @schema_name VARCHAR(500) ;
DECLARE @tab1 TABLE
(
tablename VARCHAR(500) COLLATE database_default ,
schemaname VARCHAR(500) COLLATE database_default
) ;
DECLARE @temp_table TABLE
(
tablename SYSNAME ,
row_count INT ,
reserved VARCHAR(50) COLLATE database_default ,
data VARCHAR(50) COLLATE database_default ,
index_size VARCHAR(50) COLLATE database_default ,
unused VARCHAR(50) COLLATE database_default
) ;
INSERT INTO @tab1
SELECT t1.name ,
t2.name
FROM sys.tables t1
INNER JOIN sys.schemas t2 ON ( t1.schema_id = t2.schema_id ) ;
DECLARE c1 CURSOR FOR
SELECT t2.name + '.' + t1.name FROM sys.tables t1 INNER JOIN sys.schemas t2 ON ( t1.schema_id = t2.schema_id ) ;
OPEN c1 ;
FETCH NEXT FROM c1 INTO @table_name ;
WHILE @@FETCH_STATUS = 0
BEGIN
SET @table_name = REPLACE(@table_name, '[', '') ;
SET @table_name = REPLACE(@table_name, ']', '') ;
-- make sure the object exists before calling sp_spacedused
IF EXISTS ( SELECT OBJECT_ID
FROM sys.objects
WHERE OBJECT_ID = OBJECT_ID(@table_name) )
BEGIN
INSERT INTO @temp_table
EXEC sp_spaceused @table_name, false ;
END
FETCH NEXT FROM c1 INTO @table_name ;
END ;
CLOSE c1 ;
DEALLOCATE c1 ;
SELECT t1.* ,
t2.schemaname
FROM @temp_table t1
INNER JOIN @tab1 t2 ON ( t1.tablename = t2.tablename )
ORDER BY schemaname ,
t1.tablename ;
END TRY
BEGIN CATCH
SELECT -100 AS l1 ,
ERROR_NUMBER() AS tablename ,
ERROR_SEVERITY() AS row_count ,
ERROR_STATE() AS reserved ,
ERROR_MESSAGE() AS data ,
1 AS index_size ,
1 AS unused ,
1 AS schemaname
END CATCH
Subscribe to:
Posts (Atom)