cmd.CommandText = "SP_INSERT_DriverRegister";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@DriverReg_id", HF_Reg_Id.Value);
cmd.Parameters.Add("@SeatsNumbers", txtDriverSeats.Text);
//cmd.Parameters.Add("@AvailableSeats", txtDriverAvailableSeats.Text);
//cmd.Parameters.Add("@VehicleImage",??);
how to select image from database?
Insert Method
protected void Button1_Click1(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string Extension = System.IO.Path.GetExtension(FileUpload1.FileName);
if (Extension.ToLower() != ".gif" && Extension.ToLower() != ".png" && Extension.ToLower() != ".jpg" && Extension.ToLower() != ".jpeg")
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Invalid image format');", true);
}
else
{
int FileSize = FileUpload1.PostedFile.ContentLength;
if (FileSize > 1048576)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Maximum file size 1 mb');", true);
}
else
{
string pathName = "uploadImages/" + Path.GetFileName(FileUpload1.PostedFile.FileName);
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("insert into tbl_images(images_path) values('" + pathName + "')", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
FileUpload1.SaveAs(Server.MapPath("~/UploadImages/" + FileUpload1.FileName));
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('File Uploaded.....');", true);
}
}
}
else
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('Please select a file');", true);
}
}

Nitin SontakkePosted Jul 19, 2016, 11:31 PM
Sorry, I don't think I quite understand the question. You are not quite actually storing images into the database, but just the paths.
You will need to get these path from the database and then get image from that path.