Google Analytics Alternative

Search This Blog

Wednesday, May 14, 2014

replace cursor with while loop in sql.

Declare @count int;
set @count =1;

Declare @loop int;
declare @tempItem_Id bigint;
select @loop = COUNT(item_id_big) from tbl_item_master;

while @count <= @loop
    select   item_id_big,
             RowNum = row_number() OVER ( order by item_id_big )
    from     tbl_item_master
 select @tempItem_Id = item_id_big from MyCte where RowNum = @count;

 print convert(varchar(15), @tempItem_Id)+ ' '+ convert(varchar(4),@count)  + ' \n ';
 set @count = @count+1;

Wednesday, April 3, 2013

How to get div whose id start with “panel” from page body using jquery

Query : How to get div whose id start with “panel” from page body using jquery.
solution : $('div[id^="panel_"]')
the above jquery script will return you list of div whose id start with “panel”.

Thursday, October 25, 2012

EntityFramework inner join

Column concatenation using Linq to EntityFramework.
here we have one simple example where there are two tables.
Employee with following fileds

CREATE TABLE [dbo].[empMaster](
[Id] [int] IDENTITY(1,1) NOT NULL,
[Name] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[Age] [int] NULL,
[IsActive] [bit] NULL CONSTRAINT [DF_empMaster_IsActive]  DEFAULT ((1)),
[CreatedDate] [datetime] NULL CONSTRAINT [DF_empMaster_CreatedDate]  DEFAULT (getdate()),
[Id] ASC

and another table is with

CREATE TABLE [dbo].[employee](
[id] [int] IDENTITY(1,1) NOT NULL,
[Salary] [int] NULL,
[id] ASC

Now i want to get name of employee and salary of that employee.
so i used innerjoin like this

from empMaster em
inner join employee e
Result of inner join.

but in Linq To EntityFrame work it works like this.

   var outputvalue = (from emp in obj.empMasters 
                                      join e in obj.employees on emp.Id equals
                                     select new {
                                     }).ToList().Select(q =>new {Id = q.Id,Name = q.Name,dummyValue = q.Id.ToString() + " " + 


Tuesday, October 16, 2012

Prepare DTO layer by using below script

Declare @sql nvarchar(MAX)
Declare @TmpTable table (ID int Identity(1,1), c_Column_name varchar(500),c_Data_type varchar(50),c_character_Maximum_length nvarchar(50))

Insert into @TmpTable (c_Column_name,c_Data_type,c_character_Maximum_length)
WHERE TABLE_NAME = 'TT_M_User'  --Table Name
set @CurID = 1
set @sql=''
SELECT @MaxID=Max(ID) FROM @TmpTable WHILE @MaxID >=@CurID BEGIN -- Logic to be performed
select @sql = @sql + char(13)+ ' public ' +
    case c_Data_type
    when 'varchar' then ' string '
    when 'nvarchar' then ' string '
    when 'bit' then ' bool '
    when 'datetime' then ' DateTime '
    when 'binary' then ' Byte[] '
    else c_Data_type end + ' ' + c_Column_Name + ' {get;set;} '
from @TmpTable where ID=@CurID
set @CurID = @CurID +1
print @sql

Thursday, May 24, 2012

Find job by jobberclub

Now it is too easy to find job for freshers to experts.

just visit this below link now. and search your desire profile job.

I hope it will help you.

Tuesday, May 1, 2012

Three simple character that is important in every once life.
G : Generator
O : Operator
D : Destroyer

God is Generator of life.
God is Operator of life.
and finally
God is Destroyer of life.


Saturday, April 7, 2012

ASP.NET : Difference between Server.Transfer and response.Redirect

Response.Redirect sends message to the browser saying it to move to some different page, while server.transfer does not send any message to the browser but rather redirects the user directly from the server itself. So in server.transfer there is no round trip while response.redirect has a round trip and hence puts a load on server.

Using Server.Transfer you can not redirect to a different from the server itself. Example if your server is you can use server.transfer to move to but yes you can move to, i.e. within websites. This cross server redirect is possible only using Response.redirect.

With server.transfer you can preserve your information. It has a parameter called as “preserveForm”. So the existing query string etc. will be able in the calling page.

Use server.transfer to navigate within website. And use Response.redirect to redirect to another website.

You can transfer current users page request to another page with two methods:

    * Server.Transfer (HttpServerUtility.Transfer Method)
    * Response.Redirect (HttpResponse.Redirect Method)

Its not always clear how these two approaches differ so let us try to clarify things a little:

Response.Redirect sends HTTP code 302 down to the users browser along with the new URL location of the wanted page. 
HTTP Code 302 actually means ' The requested resource resides temporarily under a different URI'.
After browser receives this code it tries to open the new location of the resource that was suggested by the server.
This actually causes two requests to the server, first one to the original URL, and second to the new URL that is suggested via 302 response.
All the Query Strings and Form variables are lost during the redirect and they are not available to the redirected URL.

Also its important to say that the new URL can reside on the same server but also it can be on some other server and the redirected URL does not need to be .aspx page it can be regular HTML page also).

So we can us the Redirect method to redirect users request to another page on our server like this:


or to redirect our it to some other server like this:


In contrast to all this when we call Server.Transfer we do not initiate another request to the server, but the original request is simply rewritten and transfered to some other page on the same server.
(This off course means that we can use it only to transfer requests to the pages on the same server, not to some other servers and we can only transfer to .aspx pages and not other page types like HTML, php etc). 

All posted Form variables and query strings can optionally remain available to the second Page where we transfered request (if we use second overload Server.Transfer(string pathbool preserveForm) and supply true for the second parameter).
Otherwise the Form Variables and Query String are cleared just like when we use Redirect.
WARNING: If you use this method to preserve Query String and Form variables and receive error: "View State Is Invalid" its because your EnableViewStateMac attribute of the <pages> element is set to true. More on this error on this page: PRB: "View State Is Invalid" Error Message When You Use Server.Transfer

Its also important to note that because of the way Server.Transfer works, after the transfer, the URL shown in the users Web Browser remains the original one that was requested, because browser has no knowledge that its request was transfered (transfer occurs on the server side).
TIP: One thing to be careful about when using the Server.Transfer is to clear the the HttpResponse object withResponse.Clear method on the transfered page to avoid any output from the first page to be shown on the second page.

So now that we know what are the similarities and differences between these two approaches we can try to use them wisely.

Here is the summary:

Response.Redirect should be used when:
  • we want to redirect the request to some plain HTML pages on our server or to some other web server
  • we don't care about causing additional roundtrips to the server on each request
  • we do not need to preserve Query String and Form Variables from the original request
  • we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its necessary)
Server.Transfer should be used when:
  • we want to transfer current page request to another .aspx page on the same server
  • we want to preserve server resources and avoid the unnecessary roundtrips to the server
  • we want to preserve Query String and Form Variables (optionally)
  • we don't need to show the real URL where we redirected the request in the users Web Browser