Wednesday, April 25, 2007

Renaming database

To rename the database, typically we have to take the database offline. But when you try to do that typically connection held to those database does not let you rename the database. So we need to take the database to Single User mode so that particular database accepts only one database connection. Dont try it take it "Single user" mode from Enterprise manager - then Enterprise manager itself will eat up the available connection and you will start sweating (If you are doing it live thinking these steps can be done quickly :)).

Go by TSQL way,

USE master GO
EXEC sp_dboption DevelopmentDB, 'Single User', True
EXEC sp_renamedb 'DevelopmentDB', 'ProductionDB'
EXEC sp_dboption ProductionDB, 'Single User', False

Wednesday, April 18, 2007

ASP Request Object

As we all know, web is all about Request and Response. You send your request to Webserver and Server sends you back the Response.

Server side programming has these 2 activities wrapped in to object called Request and Response object which help us to read or manipulate those object.

The Request Object receives the values that the client's browser passed to the server during an HTTP request.

Request Object has several namevalue "collections".
  • ClientCertificate: The values of fields stored in the client certificate that is sent in the HTTP request.
  • Cookies: The values of cookies sent in the HTTP request.
  • Form: The values of form elements in the HTTP request body.
  • QueryString: The values of variables in the HTTP query string.
  • ServerVariables: The values of predetermined server/environment variables.
The syntax is: Request[.collectionpropertymethod](variable)

All request object variables can be accessed directly by calling Request(variable) without the collection name. In this case, the Web server searches the collections in the following order:
  1. QueryString
  2. Form
  3. Cookies
  4. ClientCertificate
  5. ServerVariables

If a variable with the same name exists in more than one collection, the Request object returns the first instance encountered. It is strongly recommended that, when referring to members of the ServerVariables collection, the full name be used. For example, rather than Request("AUTH_USER") use Request.ServerVariables("AUTH_USER").