Storing a image using asp.net

Leave a comment


Hi, Use this code to store an image in the online server.

Before doing that we must give Permisiions to the folder in which you want to store Images.

Give Read and Write Permissions.

You must use fileupload control to do this:

Here is the code:

string extn =    System.IO.Path.GetExtension(FileUpload1.FileName);

if ((extn == “.jpg”) || (extn == “.gif”) || (extn == “.png”) || (extn == “.jpeg”))
{
path = Server.MapPath(“~/Documents”) + “//” + FileUpload1.FileName;
FileUpload1.SaveAs(path);

string script = “alert(‘Document Uploaded Successfully…’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “str”, script, true);

}
else
{
string script = “alert(‘Invalid File Format…’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “str”, script, true);
}
Any doubts Mail Me at radhek@gmail.com

Advertisements

Insert Null values into datetime column of SQL SERVER using asp.net,C#

6 Comments


Sometimes we will get the situation where we must insert NULL into datetime column in sql server.

Follow these steps to do that:

1) First Include the namespace:

using System.Data.SqlTypes;

2)  Declare

System.Data.SqlTypes.SqlDateTime getDate;
getDate = SqlDateTime.Null;

3) Insert using command Parameters

cmd11.Parameters.AddWithValue(“@encashed_date”, getDate);

——————————<>—————————————

%d bloggers like this: