|
 |
access thread: Store files in the database
Message #1 by myhopeful@y... on Tue, 23 Apr 2002 00:08:29
|
|
Dear All,
Could you please tell me how to store files in the database. I need to
store the Resumes people emailed to us in our database, I don't know how
to do this.
Thank you
Lily
Message #2 by "Carnley, Dave" <dcarnley@a...> on Tue, 23 Apr 2002 14:19:29 -0500
|
|
If you are using a SQL Server backend, you can use ADO GetCHunk to move the
binary file data into large binary fields. In Access you can use an Image
data type to do the same thing but I'm not exactly sure of the syntax...
prolly ADO again... read up on ADO GetChunk and Image fields.
I have an app where I have a word doc stored in an image field, its a
template of a business form, and when I need to print an instance of that
form I create the file using GetChunk and binary file operations, then open
the file using VB/Word integration, and update field codes within the word
doc with data items from that specific person stored elsehwere in the
database.
or you can store the files on your file system and store their file names in
the db, use office automation (word object library) to open and display
them. But its a lot sexier to store them as image data :)
here is code to open any file and store it in a large binary field using ADO
Open "C:" & gcTCF_TEMPLATE_NAME & ".doc" For Binary As #1
Set aC = New ADODB.Connection
aC.Open "ProdAppsMaster_DEV"
Set rA = New ADODB.Recordset
rA.Open "tbl_MasterWordTemplates", aC, adOpenKeyset, adLockOptimistic,
adCmdTable
rA.Find "WordName = 'TradeCorrectionForm'"
lngSize = LOF(1) 'total length of file.. mine are small so one chunk is
enough
varChunk = InputB(lngSize, #1)
rA!worddata.AppendChunk (varChunk)
rA.Update
rA.Close
Close 1
here is code to read binary data and create a file
Open "C:\" & gcTCF_TEMPLATE_NAME & ".doc" For Binary As #1
Set aC = New ADODB.Connection
aC.Open mvConnectString
Set rA = New ADODB.Recordset
rA.Open "tbl_MasterWordTemplates", aC, adOpenKeyset, adLockOptimistic,
adCmdTable
rA.Find "WordName = '" & gcTCF_TEMPLATE_NAME & "'"
lngSize = LenB(rA!WordData)
lngOffset = 0
Do While lngOffset < lngSize
varChunk = rA!WordData.GetChunk(conChunkSize)
Put #1, , varChunk
lngOffset = lngOffset + conChunkSize
Loop
rA.Close
Close 1
-----Original Message-----
From: myhopeful@y... [mailto:myhopeful@y...]
Sent: Monday, April 22, 2002 7:08 PM
To: Access
Subject: [access] Store files in the database
Dear All,
Could you please tell me how to store files in the database. I need to
store the Resumes people emailed to us in our database, I don't know how
to do this.
Thank you
Lily
|
|
 |