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
Jyoti Jodha
NA
1.7k
408.5k
Object reference not set to an instance of an object
Oct 6 2017 12:35 AM
Object reference not set to an instance of an object in asp.net c#
protected void Button1_Click1(object sender, EventArgs e)
{
if (!FileUpload1.HasFile)
{
Label9.Visible = true;
Label9.Text = "Please Select Image File";
}
else
{
int length = FileUpload1.PostedFile.ContentLength;
byte[] pic = new byte[length];
FileUpload1.PostedFile.InputStream.Read(pic, 0, length);
try
{
connection();
SqlCommand com = new SqlCommand("insert into Post_Room (Property_Type,Location,Mobile,Email,Rent,Description,Images) values (@Property_Type,@Location,@Mobile,@Email,@Rent,@Description,@Images)", con);
com.Parameters.AddWithValue("@Property_Type", DropDownList.SelectedValue);
com.Parameters.AddWithValue("@Location", txtlction.Text);
com.Parameters.AddWithValue("@Mobile", Txtmob.Text);
com.Parameters.AddWithValue("@Email", Txtemail.Text);
com.Parameters.AddWithValue("@Rent", Txtrent.Text);
com.Parameters.AddWithValue("@Description", Txtdec.Text);
com.Parameters.AddWithValue("@Images", pic);
com.ExecuteNonQuery();
Label9.Visible = true;
Label9.Text = "Image Uploaded Sucessfully"; //after Sucessfully uploaded image
con.Close();
}
catch (Exception ex)
{
Label9.Visible = true;
Label9.Text = ex.Message;
}
}
}
Reply
Answers (
2
)
How to apply admin boostrap into default MVC template?
price based slider for filter purpose