BLOB Binary data in database

M

MarcelV

Hi Experts,

I am trying to add documents (xl, doc, pdf, image) into our database.
In this case it will be an access database because of the local
caching. But that is not the issue.

I managed from a windows form with drag/drop or fileselecter to select
a file. I store the path in memory. When saving the information on the
screen with the path to the file I transfer the file to a byte array.

<CODE>
public static byte[] GetPhoto(string filePath)
{
FileStream fs = new FileStream(filePath, FileMode.Open,
FileAccess.Read);
BinaryReader br = new BinaryReader(fs);

byte[] photo = br.ReadBytes((int)fs.Length);

br.Close();
fs.Close();

return photo;
}
</CODE>
So far so good. Now comes the problem. I store the data with our own
created sql string. So not open a dataset and fill in the properties.
Just an easy simple "INSERT INTO....etc VALUES....

My problem is how to convert the photo byte array to a format which
will be accepted within the insert statement.

Just adding phone whil result in system.byte[] as string in the field
Just adding phone.Length will result in a few numbers.

The field in which it has to be inserted is a ole-object .

Thanks, for all help.....
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

MarcelV said:
So far so good. Now comes the problem. I store the data with our own
created sql string. So not open a dataset and fill in the properties.
Just an easy simple "INSERT INTO....etc VALUES....

My problem is how to convert the photo byte array to a format which
will be accepted within the insert statement.

Just adding phone whil result in system.byte[] as string in the field
Just adding phone.Length will result in a few numbers.

The field in which it has to be inserted is a ole-object .

Use parameters.

Arne

PS: Access is not a good DB for storing files. And even if you
store them in an OLE Object field, then they are not OLE Objects
and can not be viewed as such.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top