Thursday, September 13, 2007

Cookies

Cookies:-

Cookies
provide a useful means in Web applications to store user-specific information. For example, when a user visits your site, you can use cookies to store user preferences or other information. When the user visits your Web site another time, the application can retrieve the information it stored earlier.

A cookie is a small bit of text that accompanies requests and pages as they go between the Web server and browser. The cookie contains information the Web application can read whenever the user visits the site. Imagine that when users request a page from your site, www.contoso.com, your application sends not just a page, but a cookie containing the date and time. When the user's browser gets the page, the browser also gets the cookie, which it stores in a folder on the user's hard disk. Later, the user requests a page from your site again. When the user enters the URL www.contoso.com, the browser looks on the local hard disk for a cookie associated with the URL. If the cookie exists, the browser sends the cookie to your site along with the page request. Your application can then determine the date and time that the user last visited the site. You might use the information to display a message to the user, check an expiration date, or perform any other useful function.

Cookies are associated with a Web site, not with a specific page, so the browser and server will exchange the www.contoso.com cookie information no matter what page the user requests from your site. As the user visits different sites, each site might send a cookie to the user's browser as well; the browser stores all the cookies separately.


Limitations
§ Most browsers support cookies of up to 4096 bytes. That is plenty of space for storing a few values on the user's computers, but you would not want to try to store a dataset or some other potentially large piece of data in a cookie. More practically, you probably do not want to store a big collection of user information in a cookie.

§ Browsers also impose limitations on how many cookies your site can store on the user's computer. Most browsers allow only 20 cookies per site; if you try to store more, the oldest cookies are discarded.

§ A cookie limitation that you are likelier to run into is that users can set their browser to refuse cookies. You cannot do much to get around this problem except to avoid cookies altogether and use a different mechanism to store user-specific information.

Add more to it u know.





Wishes
Whocares

How to find sql server version installed and service pack installed.

How to find sql server version installed and service pack installed.

Some time there is need to find what service pack your sql server already have.

1. Go to Sql query analyser

SELECT @@VERSION

It will give u the output something like this:-
=>For Sql server 2000

Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright © 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4)


=>For sql server 2005
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) Oct 14 2005 00:33:37 Copyright © 1988-2005 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 4)

But Something is missing here, the service pack info of sql server is missing.

2. Go to Query analyser
SELECT SERVERPROPERTY('productversion')as ProductVersion, SERVERPROPERTY ('productlevel')as ProductLevel, SERVERPROPERTY ('edition') as ServerEdition

=>Output of query for Sql server 2000 is

ProductVersion : ProductLevel : ServerEdition
8.00.760 : SP3 : Enterprise Edition

=>Output of query for Sql server 2005 is

ProductVersion : ProductLevel : ServerEdition
9.00.1399.06 : RTM : Enterprise Edition

How to get only Column name returned as result., Info

Sometimes in programming we just need to return the column name for a given table.

To solve this

1. Write a simple query:-

select name from syscolumns where id = object_id ('Typeurtablenamehere')


to see more attributes write
select * from syscolumns where id = object_id ('Typeurtablenamehere')

2. Also other method:-

select * from tablename where 1=0

It will give only the column name as output..


3. Also One more:-

select Column_NAME from information_schema.columns where table_name = 'Typeurtablenamehere'


Add more to this if some other methods is there also.

Enjoy....
..
.

Wednesday, May 23, 2007

Some Date time Facts in sql server

How to convert Datetime to only time
select CONVERT(VARCHAR(10), GETDATE(),101)

It will convert the date into varchar in mm/dd/yyyy format.

select CONVERT(VARCHAR(10), GETDATE(),103)
It will convert date in to varchar in dd/mm/yyyy format.

How to convert Datetime in format date and time 00.00.00

select convert(datetime, convert(varchar, getdate(), 101))

How to find Date difference
Use DATEDIFF(d, startdate, endddate) to return the number of day
DATEDIFF(yy, startdate, endddate) to return the number of year
DATEDIFF(m, startdate, endddate) to return the number of months


Convert datetime to String, suppose if u want to compare
select CONVERT(VARCHAR(10), GETDATE(),112)

convert datetime to string in format yyyymmdd,
09/05/2006 = 20060905
02/06/2007 = 20070206

Sleepy sleepy..............

Time to sleep....
Enjoy.....

Any other query regarding this, reply to the post.

Thursday, May 17, 2007

How to add the assembly from GAC

1. Go to Visual studio command Prompt
2. type gacutil /l Myassembly
3. Note down the version and Public key token
4. for example version 1.0.0.0 and public key token= 4596487adasfaf
5. now click on the project where u want to add the reference.


In browse give path C:\WINDOWS\assembly\GAC_MSIL\Myassembly\version__Publickey token\myassembly.dll


Replace the version and publickeytoken with ur assembly version.
For example:-

C:\WINDOWS\assembly\GAC_MSIL\Myassembly\1.0.0.0__4596487adasfaf\myassembly.dll


Another doin same

Go TO
1. HKLM/Software/microsoft/fusion
2. Right click in right pane and click new , create new dword value' DisableCacheViewer'(without quotes) and set it value to one.
3. Now go to c: WINDIR/Assembly Folder, search for ur DLL and add reference to it through the Visual studio add reference browse option.


Only one of the methods of how to do it......



It will add the required reference.

Tuesday, May 8, 2007

Performance difference between Count(*) vs Count(1)

Both will give the same performance.

Lets consider the scenerio,

Case 1:- Sql server stores internally everything in pages of size 8kb.
So if we using count (1) or the count (*), actually we r dealing with these 8kb(8060 bytes to be precise)
So it doesnot matter if we use count(1) or Count(*), we r dealing with 8kb interal storage of pages.

Case2:-

Suppose we have a index in the table for which we r retreiving count(*) and count(1)

Sub case(A):- Suppose index is on the column which i am using in count.
In this case count(*) and count(1) will both use the same index and perform same.

Sub case(B): Suppose index is not on the column which we r using count(1)
In this case COunt (*) will use the default index but count(1) will not use it.
So count(1) will be slower if index is not on one.



If u like this post reply.

Wishes
whocares

Design Mode disabled in Asp.Net

Sometime in Asp.net The Design mode is disabled. So the solution is not to reinstall the .Net or all that stuff , but to Go to Visual studio Command prompt window and write the below command and Press enter.
devenv /resetskippkgs

Enjoy.......

Monday, May 7, 2007

How to find The occurence of a particular Column in a database

How to find The occurence of a particular Column in a database

SELET O.Name
FROM sysobjects AS O
JOIN syscolumns AS C
on C.id = O.ID
WHERE C.Name = 'columnName'

sysobjects :To find the tables
syscolumns:-To locate a specific column