Solved

Access DB and Zip Files

Posted on 1998-10-20
6
155 Views
Last Modified: 2010-04-30
I'm developing a VB5 application.  I', using Access 97 database to store zip files in binary large fields.
I 've developed under Windows 95.  All works fine.  But if I run the app in Windows 98, unziping fails.
Why ?
Thanks in advance
0
Comment
Question by:CarlosJac
6 Comments
 
LVL 1

Expert Comment

by:steve06
ID: 1440805
CarlosJac,

You should check the association of .ZIP in explorer. As you may know, Win98 is able to handle ZIP files as special folders, and it is far from being efficient. I came back, via reset of this association to Winzip.

Steve.
0
 
LVL 1

Author Comment

by:CarlosJac
ID: 1440806
steve:

The zip files already are associated to WinZip
thanks
0
 
LVL 5

Expert Comment

by:chewhoung
ID: 1440807
Why don't you just store the link instead of the file?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:CarlosJac
ID: 1440808
chewhoung: To avoid problems if anyone move the files ...
0
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1440809
Try those functions, I do the same thing, and works :

Sub GetFileFromDB(BinaryField As Field, szFileName As String)
   ' *** Will retrieve an entire Binary field and write it to disk ***

   Dim NumBlocks    As Long
   Dim TotalSize    As Long
   Dim RemBlocks    As Integer
   Dim CurSize      As Integer
   Dim nBlockSize   As Long
   Dim nI           As Integer
   Dim nFile        As Integer
   Dim CurChunk     As String

   If IsNull(BinaryField) Then Exit Sub

   nBlockSize = 32000    ' Set size of chunk.

   ' *** Get field size.
   TotalSize = BinaryField.FieldSize()
   NumBlocks = TotalSize \ nBlockSize   ' Set number of chunks.

   ' *** Set number of remaining bytes.
   RemBlocks = TotalSize Mod nBlockSize

   ' *** Set starting size of chunk.
   CurSize = nBlockSize
   nFile = FreeFile ' Get free file number.

   Open szFileName For Binary As #nFile  ' Open the file.
   For nI = 0 To NumBlocks
      If nI = NumBlocks Then CurSize = RemBlocks
      CurChunk = BinaryField.GetChunk(nI * nBlockSize, CurSize)
      Put #nFile, , CurChunk   ' Write chunk to file.
   Next
   Close nFile

End Sub

Function SaveFileToDB(sSource As String, BynaryField As Field) As Integer
   ' *** Will save a file to a Binary field

   Dim nNumBlocks       As Integer
   Dim nFile            As Integer
   Dim nI               As Integer
   Dim nFileLen         As Long
   Dim nLeftOver        As Long
   Dim sFileData        As String
   Dim Retval           As Variant
   Dim nBlockSize       As Long

   On Error GoTo Error_SaveFileToDB

   nBlockSize = 32000    ' Set size of chunk.

   ' *** Open the sSource file.
   nFile = FreeFile
   Open sSource For Binary Access Read As nFile

   ' *** Get the length of the file.
   nFileLen = LOF(nFile)
   If nFileLen = 0 Then
      SaveFileToDB = 0
      Exit Function
   End If

   ' *** Calculate the number of blocks to read and nLeftOver bytes.
   nNumBlocks = nFileLen \ nBlockSize
   nLeftOver = nFileLen Mod nBlockSize

   ' *** Read the nLeftOver data, writing it to the table.
   sFileData = String$(nLeftOver, 32)
   Get nFile, , sFileData
   BynaryField.AppendChunk (sFileData)

   ' *** Read the remaining blocks of data, writing them to the table.
   sFileData = String$(nBlockSize, Chr$(32))
   For nI = 1 To nNumBlocks
      Get nFile, , sFileData
      BynaryField.AppendChunk (sFileData)
   Next
   Close #nFile
   SaveFileToDB = nFileLen

   SaveFileToDB = 0

   Exit Function

Error_SaveFileToDB:
   SaveFileToDB = -Err
   Exit Function
   
End Function

0
 
LVL 1

Author Comment

by:CarlosJac
ID: 1440810
waty:
Thank you
I 'll test your answer later.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now