TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sundas Ali
NA
7
7k
Select image from database
Jul 19 2016 3:08 PM
<asp:Image ID="Image1" runat="server" />
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);
}
}
Reply
Answers (
1
)
How to Call Controller Actions using JQuery in ASP.NET MVC 4
C# MVC SQL database