Hi,
I have an access database with one field of type OLE Object. I want to insert a picture and I have this code:
byte[] imageData = ReadFile(textBox15.Text);
com.Parameters.AddWithValue("@Slikadog", imageData);
byte[] ReadFile(string sPath)
{
byte[] data = null;
FileInfo fInfo = new FileInfo(sPath);
long numBytes = fInfo.Length;
FileStream fStream = new FileStream(sPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fStream);
data = br.ReadBytes((int)numBytes);
return data;
}
void GetImagesFromDatabase()
{
try
{
OleDbDataAdapter ADAP = new OleDbDataAdapter("Select Slikadog from Dogovor", conn);
DataSet DS = new DataSet();
ADAP.Fill(DS, "Dogovor");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
but when I run the application, in the database Ole Object field (the image field) I get only "Long binary data"
I don't know whether this is the right way to insert picture from a file. Please help me.
Thank you in advance.
Loading
Satyapriya NayakPosted Feb 1, 2012, 10:17 AM
Please refer the below links
http://support.microsoft.com/default.aspx?scid=kb;en-us;317016&Product=vcSnet
http://www.mikesdotnetting.com/Article/123/Storing-Files-and-Images-in-Access-with-ASP.NET
http://satishjdotnet.blogspot.in/2009/04/save-images-in-access-database-aspnet.html
Thanks
NelPosted Feb 2, 2012, 4:40 AM
VulpesPosted Feb 1, 2012, 10:54 AM
Pravin GhadgePosted Feb 1, 2012, 10:24 AM
The problem may be image size is too large.
What type of image u r trying to insert?
U try to insert differnt type of images say .bmp ,.jpg
Then check whether all types of images giving u same error or r getting inserted in db.