Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you run a VB/MS Access app from a CD 2

Status
Not open for further replies.

edge27

Programmer
Jun 23, 2003
12
0
0
US
Hi,

I have used the VB6 package wizard to create the setup for my Vb app. It reads an access database. I used Roxio to burn it to a CD. My client wants users to be able to run it off the CD since some users wont have admin rights to their pc. Is this possible? If so, how? My OpenDatabase keeps failing. I'm a newbie so as specific of an answer would be appreciated.
Please help.

John
 
Hey

I believe the database read fails as it is on the cd and only read only.

C
 
This is the OpenDatabase code I tried:
Set dbData = OpenDatabase(App.Path & "\PB2006Data.mdb", , vbReadOnly)

First it gives me a "Runtime error 5" message (only get that when I run from the CD and only since I added the readOnly parameter) and then after the OpenDatabase it goes to my error handler.
 
Hello,

The problem is that when an Access database is opened, it creates a lock file in the same directory. If you don't have write access to the directory, it will always fail. The other problem that I see is that they will not be able to write to the database at any time.

An alternative is to use a network share that they have read/write access to.

Also, I'm confused as to why they would need to have admin rights on their PC. In order to run an app, you only need user level access. The installation will still have to be done by a local admin in order to register the installation.
 
Thanks for the info so far macleod1021,

There is no shared directory. The users will be completely off site and possibly no internet connection. All files need to be contained within the CD including the database.

I'm a bit confused myself so far as admin rights go. When you run a setup won't it update your registry and don't you need admin rights to your pc to do that. For security reasons, many of our users pc's are in that situation.
 
That's correct Edge, once the app is installed you only need to be able to log in to use it (unless the PC admin locked it down). In addition to this, the VB6 app will have to be installed on the computer prior to being used, even if it is run from a CD. By trying to put it on a CD, the client is causing a lot of headaches for themselves.

As a secondary option, if they insist on using a CD, you can write it as part of your code to copy the database to their My Documents folder upon launch then delete when the app closes.
 
The first issue is your VB program.

IF it is a "bare EXE" (no dependencies need be installed such as DLLs or OCXs), and

IF it only needs a few passive support files like text or image files that can be on the CD, and

IF the pre-installed MDAC on your clients' machines is "good enough" for your program, and

IF the pre-installed VB6 runtime on the clients' machines is there and is recent enough (no obstructing bugs) for your program to run ok

THEN You may just get away with this.


The trick may be the MDAC version. Using DAO all bets may be off here. If you were using ADO instead, you might be able to get away with compiling against the "ADO 2.0" type library (if you don't use Record objects).

How To Develop with ADO Version 2.5 or Later and Install on ADO Version 2.0


All of that is in regard to the unrecommended practice of "XCopy deployment" of VB6 programs. I.e. where you don't use an installer (setup.exe, etc.) at all but want to run "bare VB programs." There may be other issues as well, but those are probably the highlights.


Regarding the database...

This WSH VBScript works fine and never requires an LDB (lockfile):

RO-MDB.wsf
Code:
<job>
  <reference object="ADODB.Recordset"/>
  <object id="rsRO" progId="ADODB.Recordset"/>
  <object id="cnRO" progId="ADODB.Connection"/>
  <script language="VBScript">
    'The sample.mdb has a table called Names
    Option Explicit

    cnRO.Mode = adModeShareDenyWrite
    cnRO.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=sample.mdb;"

    rsRO.Open "SELECT * FROM [Names]", _
              cnRO, adOpenStatic, adLockReadOnly, adCmdText
    MsgBox CStr(rsRO.RecordCount) & " records"
    rsRO.Close
    cnRO.Close
  </script>
</job>

It does require an explicit ADO Connection object even if you could otherwise get by with just a Recordset.

The VB6 to do the same thing should be nearly identical.


See ACC2000: How to Open a Database from Read-Only Media with Microsoft Jet 4.0 and ADO for ADO.

See PRB: DAO MDB on Read-Only Media Must Be Opened Exclusively for DAO.


Note that DAO is largely an obsolete technology, though it does still do well for some specific types of application issues. In general you should probably have moved to ADO long ago though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top