PC Review


Reply
Thread Tools Rate Thread

BLOB Binary data in database

 
 
MarcelV
Guest
Posts: n/a
 
      7th Sep 2006
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.....

 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Arne_Vajh=F8j?=
Guest
Posts: n/a
 
      8th Sep 2006
MarcelV wrote:
> 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.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
convert Binary Stream to BLOB? roger Microsoft Access VBA Modules 2 16th Oct 2008 04:58 PM
Data conversion for "long binary fields" (blob)? Susan Microsoft Access Getting Started 1 30th Sep 2007 08:52 PM
chunking in binary (BLOB) data for generic providers Michael Burstin Microsoft ADO .NET 10 28th Sep 2006 03:24 AM
How to store integer-array in SQL-Database in a BLOB ( Binary large object ) Peter Stojkovic Microsoft VB .NET 10 1st Jun 2004 05:37 PM
Binary blob serialization Atul Microsoft Dot NET Framework 1 4th Oct 2003 02:59 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 AM.