• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 184
  • Last Modified:

Load my App on a CD

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
kanthiperera
Asked:
kanthiperera
1 Solution
 
appariCommented:
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
 
TimCotteeCommented:
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
 
deightonCommented:
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
 
deightonCommented:
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
 
glass_cookieCommented:
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

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now