i want bind image control sql database. saving image path in sql database , retrieving image path database.when check through breakpoint shows me path of image image not binding here code
string imagepath = server.mappath("~/pics/"); string serverfilename = path.getfilename(asyncfileupload1.postedfile.filename); string fullpath = path.combine(imagepath, serverfilename); string path = "~\\pics\\" + serverfilename; //string filename = system.io.path.getfilename(asyncfileupload1.filename); //string path = server.mappath("~/pics/") + filename; asyncfileupload1.saveas(fullpath); // fileupload1.postedfile.saveas(path); sqlcommand cmd = new sqlcommand("insert findfriend values('" + path + "','" + textbox1.text + "')", con); cmd.commandtype = commandtype.text; cmd.executenonquery(); sqlcommand getimage = new sqlcommand("select * findfriend name='" + textbox1.text + "'", con); getimage.commandtype = commandtype.text; sqldataadapter da = new sqldataadapter(getimage); dataset ds = new dataset(); da.fill(ds); image1.imageurl = ds.tables[0].rows[0][1].tostring();
please tell me doing wrong
i think have forgot add image page.
page.controls.add(yourimage);
if have existing image check if image uploaded , exists in directory.
Comments
Post a Comment