Solved

Load my App on a CD

Posted on 2002-07-04
5
171 Views
Last Modified: 2010-05-02
Hi,
Any help would be greately appreciated!

My VB application is ready to go to my customers. I need to load it on to a CD. My question is the database. Database is large,around 500MB. When my Cd is setting up files on customers PC, I don't want to keep such a large file on their PC. Is there a way to access the database file if still it is on CD. Can I hardcode the database path? How do I verfy the CD Driver. The Driver is different in different machines. Could anyone help me please.

Kanthi
0
Comment
Question by:kanthiperera
5 Comments
 
LVL 39

Expert Comment

by:appari
ID: 7130095
what database are you using? is it is readonly? and users are not supposed to update to that DB? if so you can give it on cd and restrit them to use it from CD.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7130143
If your database is used read-only and is MS Access then it is ok, however you must set the database access to Exclusive Read-only as Access will otherwise try to create the .ldb file on the CD which will fail.

There are API methods that allow you to determine the CD drive on a given system and you can use this as your database path.
0
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
ID: 7130188
Option Explicit

Dim db As Database

Dim fso As Object

Const spath = "\db1.mdb"   'your path to change (e.g. \accounts\file.mdb)

Private Function CDRoms() As Collection

Dim colX  As Collection

Dim drv As Object
Dim sDrive As String
Dim i As Integer

Set colX = New Collection


For i = 1 To 26

    sDrive = Chr(Asc("a") + i - 1)
    If fso.DriveExists(sDrive) Then
        Set drv = fso.GetDrive(sDrive)
        If drv.DriveType = 4 Then colX.Add sDrive
    End If
   
   
   
Next

Set CDRoms = colX
Set drv = Nothing

End Function

Private Function OpenDb() As Long


Dim x As New Collection
Dim sDrive
Dim sTarget




Set x = CDRoms()

For Each sDrive In x
    sTarget = sDrive & ":" & spath
    If fso.GetDrive(sDrive).IsReady Then
        If Len(Dir(sTarget)) Then
            Set db = Workspaces(0).OpenDatabase(sTarget, True, True)
            OpenDb = True
            Exit For
        End If
    End If
Next
   



End Function

Private Sub Form_Load()

Set fso = CreateObject("Scripting.FileSystemObject")
If Not OpenDb Then MsgBox "where's your db?": End

End Sub
0
 
LVL 18

Expert Comment

by:deighton
ID: 7130221
i've used dao above, but once th database file is located you could open it with other method such as ado in your project.

i used the scripting file, so you may need to distribute scrrun.dll

you can only open file read only and exclusive use, so there is no hope of users changing data.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 7130868
Hi!

Do this, if you do not want to deploy them in using the package and deployment wizard.  By the way, this would only work if you're not using any 3rd party ocx or dll files that are not found on standard windows PCs.  The users must also have the version of your MS Access (or higher, I suppose - if you're using MS Access) on their PCs.

Copy your vb app exe file, VB runtime file (Msvbvm60.dll) together with all the ocx files that you've used into the same folder on your CD.

If your files vb app exe file is in the root directory, the files mentioned above must also be in the root directory.

For convinience (for the coding below), place the database file in the same folder as that of your vb exe file.  If not, you'll have to modify the coding below yourself : )

The database path would be something like:

Dim DBasePath As String
If Len(App.Path) = 3 Then
DBasePath = App.Path & "MyDatabase.mdb"'or whatever is your database filename
Else
DBasePath = App.Path & "\MyDatabase.mdb"
End If

That's it!

glass cookie : )
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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

863 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

24 Experts available now in Live!

Get 1:1 Help Now