Thanks the code worked. But can you help me with a code that Will insert information into the database like names and address With a picture. And i want after uploading the picture it will Appear on the image map on the form. Can you help me on yhat?
Store the return value in a sqlcommand parameter and pass it to sqlcommand (containing insert to DB table) . The normal text like name and address can directly be assigned to parameter.
micahdavid20...
Member
3 Points
73 Posts
Code that will insert information into database with picture
May 07, 2012 01:40 PM|LINK
Split off from http://forums.asp.net/t/1791798.aspx/5/10?connecting+and+selecting+a+data+from+the+database+through+one+text+field+in+visual+studio+2010. A new question deserves a new thread.
Thanks the code worked. But can you help me with a code that Will insert information into the database like names and address With a picture. And i want after uploading the picture it will Appear on the image map on the form. Can you help me on yhat?
Ravi Kumar K...
Member
727 Points
155 Posts
Re: Code that will insert information into database with picture
May 09, 2012 10:35 AM|LINK
Code to insert information into database like names and address with a picture
Considering that the picture is being uploaded through the FileUpload WebControl, just convert it into binary and store into Database in image field.
The code is
private byte[] GetByteArrayFromFileField(System.Web.UI.WebControls.FileUpload fileField)
{
byte[] bytdata = new byte[fileField.PostedFile.ContentLength];
fileField.PostedFile.InputStream.Read(bytdata, 0, fileField.PostedFile.ContentLength);
return bytdata;
}
Store the return value in a sqlcommand parameter and pass it to sqlcommand (containing insert to DB table) . The normal text like name and address can directly be assigned to parameter.