Creating a file from and OLE Object

G

Guest

I have a Dlls stored in an OLE Object field in my database that i put there
by copy/paste into the table. What I want to do is check to see if the file
exists in the folder with the database at main form open and if not write the
file from the database to the folder. I have found an example to write excel
and word files but nothing for other file types. I also looked at Stephen
Lebans's site and found a procedure to do this but it requires a dll in the
folder with the database which puts me back at my original issue, the dlls
may not be there...

Thanks for your help,

Jim
 
G

Guest

Doug,

My question really has nothing to do with registering dlls or dlls
specifically. All I want to do is press a button on a form that gets the
file c:\abc.dll from the drive, writes it into an OLE Object field
fldRequiredFiles in table tblFiles. Then have another button that takes the
file from the table and writes it to the drive.

From what I have learned so far is, the Copy/Paste of the file from the
drive to the OLE field causes it to show up in datasheet view as "Package"
I've been told it should say "Long Binary Data". The problem with the
"Package" is that when I "put" the OLE data to disk the file ends up 1k
larger than the original which causes the dll not to work.

I was able to code a "get" that reads the file and writes it to the OLE
field, it does appear as "Long Binary Data" in datasheet view however, it
only gets 1k and the file is 88k, when I "put" the file back to disk it is 1k
in size.

Thanks for any help,

Jim
 
D

Douglas J. Steele

It's been a while since I've looked at Peter's database, but I thought
that's what it did: stored the dlls as blobs in the database, and then wrote
the files out to the hard drive if necessary.
 
G

Guest

Doug,

I created a new database, brought in the code, and ran it. It created the
Libraries table and put a couple of files in it. I deleted the data in the
table and attempted to call the PackRefs sub routine with PackRefs "text",
"me.txt", "C:", "" and PackRefs "text", "me.txt", "C:\", "". I have a me.txt
file in the root of C:, I was just trying to see if I could get anything to
work. The routine errors out at "ReDim bData(0 To FileSize - 1) As Byte"
with "9 Subscript out of range". Any suggestions?

I'm trying to cut down the code to only what I need to accomplish the
seemingly simple task of reading and writing a file...

Thanks,

Jim
 
D

Douglas J. Steele

What did you pass as strFileName to PackRefs? Was it an existing file?

Put a break point in PackRefs right after the line rst.AddNew. What value is
returned for hFile by the call to CreateFile? What value is returned for
FileSize by the call to GetFileSize?
 
G

Guest

Doug,

The call was PackRefs "text", "me.txt", "C:\", ""
strRefName = "text"
strFileName = "me.txt"
strFullPath = "C:\" I also tried it without the "\"
strGUID = "" I also tried it with strGUID = "1"

GENERIC_READ = -2147483648
FILE_SHARE_READ = 1
FILE_SHARE_WRITE = 2
OPEN_EXISTING = 3
hFile returned = -1

FileSize = -1

Hope this helps... Thanks again,

Jim
 
D

Douglas J. Steele

I believe you need to pass the full path to the file:

PackRefs "text", "me.txt", "C:\me.txt", ""
 
G

Guest

Doug,

That was it, it works. I was able to read in/write out the dlls and run the
application that uses the dlls and it works...

Thanks for your patients,

Jim
 

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