if (FileUpload1.PostedFile.ContentType.StartsWith("image/jpeg"))
{
string imgname = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf("\\") + 1);
FileUpload1.PostedFile.SaveAs(Server.MapPath("images/") + imgname);
con.Open();
SqlCommand cmd = new SqlCommand("select max(id) from image", con);
SqlDataReader dr = cmd.ExecuteReader();
dr.Read();
int id = 0;
if (dr[0].ToString() == "")
{
id = 100;
}
else ...
Go to the complete details ...