Solved

Load my App on a CD

Posted on 2002-07-04
5
170 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
VBA loop through headers using value 3 48
Help in WHSCRIPT 9 41
Saving history changes to sub form 4 24
VBA filters 2 37
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

707 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