Solved

Access DB and Zip Files

Posted on 1998-10-20
6
154 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

27 Experts available now in Live!

Get 1:1 Help Now