473,385 Members | 1,983 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

can't find binary data stored in MS access 2000 database

RN
Hi everyone,
First please let me explain. I am attempting to store pdf files in an MS
Access DB (2000) and I have written a subroutine to do this. My code seems
to work perfectly (see code below).

Imports System.IO

Imports System.Data.OleDb

Sub StoreFile(ByVal Field As String, ByVal FileName As String, ByVal
Condition As String)

Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM Table WHERE " &
Condition, strConn)

Dim cb As New OleDb.OleDbCommandBuilder(da)

Dim strConn As String = "Provider=microsoft.jet.oledb.4.0; data
source=" & "C:\data.mdb"

Dim dbConnection As New OleDbConnection(strConn)

Dim ds As New DataSet()

Dim arr() As Byte 'Create array (check the data type - Byte)

dbConnection.Open()

'****************Read file into the binary
array********************************************* ****************************************

da.Fill(ds)

ReDim arr(FileLen(FileName) - 1) 'Resize array to the same
size as length of file

FileOpen(1, FileName, OpenMode.Binary, OpenAccess.Read,
OpenShare.Shared) 'Open the file for reading

FileGet(1, arr) 'Read the file into array (just
one line...)

FileClose(1) 'Close file

'************************************************* ************************************************** ***********************************

'*************Save array data to
database****************************************** ***********************************************

ds.Tables(0).Rows(0).Item(Field) = arr 'Store element in array into
column(BinaryData) of the row(0).

da.Update(ds) 'Update database

'************************************************* ************************************************** ************************************

dbConnection.Close()

End Sub

I then use the following code to load a directory of pdf files into the DB.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim dir_info As New DirectoryInfo("C:\X")

Dim file_infos() As FileInfo

Dim i As Integer = 1

Dim file_info As FileInfo

file_infos = dir_info.GetFiles("*.PDF")

For Each file_info In dir_info.GetFiles("*.PDF")

StoreFile("BinaryData", "C:\X", "PN = 'part" & "i")

i = i + 1

Next

End Sub

The problem is that it only works for the very first file. When I look in
the DB I see "Long Binary Data" in the correct field for the first record
but the same field for all the other records are empty. The field data type
is OLE Object.

The odd thing is that the DB file size will grow to almost the same size as
the folder of pdf files that I am trying to store in the DB (700MB).

If I use the [Compact and Repair] function in access the file goes back to
its original size (3.16MB).

What am I doing wrong? Is this an Access problem? Any and all help is
welcome. Much thanks.
Jun 5 '07 #1
0 1504

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Zen | last post by:
I'm using Access 2000, and I'd like to know if there is a way to use a scanner (flatbed, doc-feed, etc) to scan forms with OMR or OCR software, and have the data be automatically (or if not...
3
by: Annette Massie | last post by:
I have a database that contains complaint information in regards to Law Enforcement. They need to have this database secure and out of reach for all but two users. (including me, they say). In...
4
by: Vikrant | last post by:
Hey friends Can someone please suggest that how many recordset can be opened simultaneously for a MS-Access 2000 Database.Does that make any difference if we use ODBC or some other way of...
4
by: ronald balk | last post by:
Dear people, after many efforts I'm putting my hope on you. Last week I changed a lot of forms and reports in an Access 2000 database. It all worked fine and I closed the database without any...
3
by: Doug | last post by:
Working on converting an Access front-end/SQL Server back-end to a .NET front/SQL Server back-end. We are also redesiging the SQL Server database. We have many Word/Excel documents that have...
3
by: Richard Cleaveland | last post by:
A client has just successfully upgraded from Access 97 to 2000. I don't have Access 2000, but I do have Office XP. Can I successfully use my Access on their database? They kind of did this...
6
by: sajohn | last post by:
Hi A separte application is sending me a pointer to some binary data and I need to find the size of the binary data being passed to me. Does anyone know I can go about doing this? TIA
13
yolenman
by: yolenman | last post by:
Hello - This is my first posting to this group, so please bear with me. Also note, that while I'm intelligent, databases are not in my field of knowledge. I'm working with a small limousine...
1
by: Swan | last post by:
Any one plz tell me ,can I send binary data from ASP to VB without writting to local hard drive.
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.