c# - Image not save in database -


i inserting image in database. problem when click upload records inserted in database except image. code not generating errors. image column blank in table.

thanks in advance.

this code:

        int length = fileupload1.postedfile.contentlength;         byte[] pic = new byte[length];         fileupload1.postedfile.inputstream.read(pic, 0, length);          try         {             sqlconnection con = new sqlconnection(conn);             con.open();             //inserting uploaded image query             sqlcommand com = new sqlcommand("insert upload (id,i_want_to,property_type,property_type1,city,locality,society_or_project_name,bedroom,bathroom,balcony,super_build_up_area,super_build_up_area_1,build_up_area,build_up_area_1,carpet_area,carpet_area_1,expected_price,property_on_floor,total_floor_in_building,transaction_type,property_ownership,availability,age_of_property,possession_of_property,image_1,property_description,full_name,email,pass,contact) values (@id,@i_want_to,@type_of_property,@type_of_property_1,@cities,@locality,@society_or_project_name,@bedroom,@bathroom,@balcony,@super_build_up_area,@super_build_up_area_1,@build_up_area,@build_up_area_1,@carpet_area,@carpet_area_1,@expected_price,@property_on_floor,@total_floor_in_building,@transaction_type,@property_ownership,@availability,@age_of_property,@possession_of_property,@image_1,@property_description,@fullname,@email,@pass,@contact)", con);              com.parameters.addwithvalue("@id", rand()).tostring();             com.parameters.addwithvalue("@i_want_to", i_want_to.selectedvalue).tostring();             com.parameters.addwithvalue("@type_of_property", type_of_property.selectedvalue).tostring();             com.parameters.addwithvalue("@type_of_property_1", type_of_property_1.selectedvalue).tostring();             com.parameters.addwithvalue("@cities", cities.text).tostring();             com.parameters.addwithvalue("@locality", locality.text).tostring();             com.parameters.addwithvalue("@society_or_project_name", society_or_project_name.text).tostring();             com.parameters.addwithvalue("@bedroom", bedroom.selectedvalue).tostring();             com.parameters.addwithvalue("@bathroom", bathroom.selectedvalue).tostring();             com.parameters.addwithvalue("@balcony", balcony.selectedvalue).tostring();             com.parameters.addwithvalue("@super_build_up_area", super_build_up_area.text).tostring();             com.parameters.addwithvalue("@super_build_up_area_1", super_build_up_area_1.selectedvalue).tostring();             com.parameters.addwithvalue("@build_up_area", build_up_area.text).tostring();             com.parameters.addwithvalue("@build_up_area_1", build_up_area_1.selectedvalue).tostring();             com.parameters.addwithvalue("@carpet_area", carpet_area.text).tostring();             com.parameters.addwithvalue("@carpet_area_1", carpet_area_1.selectedvalue).tostring();             com.parameters.addwithvalue("@expected_price", expected_price.text).tostring();             com.parameters.addwithvalue("@property_on_floor", property_on_floor.selectedvalue).tostring();             com.parameters.addwithvalue("@total_floor_in_building", total_floor_in_building.selectedvalue).tostring();             com.parameters.addwithvalue("@transaction_type", transaction_type.selectedvalue).tostring();             com.parameters.addwithvalue("@property_ownership", property_ownership.selectedvalue).tostring();             com.parameters.addwithvalue("@availability", availability.selectedvalue).tostring();             com.parameters.addwithvalue("@age_of_property", age_of_property.selectedvalue).tostring();             com.parameters.addwithvalue("@possession_of_property", possession_of_property.text).tostring();             com.parameters.addwithvalue("@image_1", pic);             com.parameters.addwithvalue("@property_description", property_description.text).tostring();             com.parameters.addwithvalue("@fullname", fullname.text).tostring();             com.parameters.addwithvalue("@email", email.text).tostring();             com.parameters.addwithvalue("@pass", password.text).tostring();             com.parameters.addwithvalue("@contact", contact.text).tostring();              com.executenonquery();              response.write("<script>alert('congratulations, have upload property details');</script>");             response.redirect("index.aspx");             com.dispose();         }                 {             con.close();         } 

stop doing that. not store images in database. can't remeber how many people have stopped doing this. save file directory , it's path store db string, , nothing else touches ever.


Comments