DotNet Friends

June 21, 2008

Differences between application and session

Application variable which remain common for the whole application (your website). Application variable’s value used in whole application. Application state allows you to store global objects that can be accessed by any client. The example of the application variable is site user count.

Session variable which are common for whole application but for particular user. Session is maintain in the page means you can create new session and use to. Example of this when user is login into the site at that time we create one session called user. After the log off we kill this session.

June 11, 2008

Debugging SQL Server 2005 Stored Procedures Using Visual Studio

Steps :

1) Open Visual Studio Interface.

2) Open Server Explorer (short cut key for that is ctrl + alt + S or Go to View Menu and Select) .

3)Now Select you database.

3.1) Right Click On Data Connections.

3.2) Select Add Connection. below interface is open. in Interface fill the below information.

1) Server Name

2) Select whether use Windows Authentication or Sql Server Authentication

3) Select Database From Available List or Attach Database

image

4) Select Store Procedures. and Add New Store Procedure in it.

image

5) configure visual studio for debug sql store procedure.

here if you not open any project then open simple project ( i opened asp.net web site).

6) select start up option (Open Menu Web Site –> Start Option). Below Interface Is Open.Tick Sql Server.

image

7) Select Any SP From SP List. and put a break point there.

8 ) right click on the store procedure and Select Step Into Stored Procedure.

image

9) Now SP Debugging Start.

Thanks.

http://amitpatriwala.blogspot.com/

June 9, 2008

Create Thumb Image In Asp.net

here is the steps:

1) create the simple web application (Asp.net using C#).

Add Name Space using System.IO

2) put the image file in to the application (here i used Sunset.jpg it’s resolution is (800 ,600)).

3) put the one button (id =btnGenerateThumbImage)

4) put the below code in to the click event of the button.

//here is the file name
string ImageFileName = “sunset.jpg”;
//create the image object here and gice the filename
//retrive the physical path of the file
System.Drawing.Image image = System.Drawing.Image.FromFile(Server.MapPath(ImageFileName));

//here is create the object for the newly image
//give the width and height for that image
System.Drawing.Image newImage = image.GetThumbnailImage

(75, 75, new System.Drawing.Image.GetThumbnailImageAbort(Callback), IntPtr.Zero);

// create the object for memory stream
MemoryStream ObjMemoryStream = new MemoryStream();

// save the image in to memory stream and here i used the format jpeg
newImage.Save(ObjMemoryStream, System.Drawing.Imaging.ImageFormat.Jpeg);

// create byte array the same size as the new image
byte[] imageContent = new Byte[ObjMemoryStream.Length];

// asign the position to the memory stream
ObjMemoryStream.Position = 0;
ObjMemoryStream.Read(imageContent, 0, (int)ObjMemoryStream.Length);
Response.ContentType = “image/jpeg”;

Response.BinaryWrite(imageContent);

5) put the below function in to the file which is not important but use it.
/// these is not Required but simple use
        public bool Callback()
        {
            return true;
        }

thnx

http://amitpatriwala.blogspot.com/

Blog at WordPress.com.