Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 25th, 2006, 12:51 AM
Registered User
Join Date: Oct 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default using app.path in database path and filename

I'm creating an application on my E drive. This application uses an access database. In the property list for the data control when I browse for the database location is assigns it as e:/shopkeeper/shopkeeper.mdb. This isn't a problem while debuging and developing. But when creating the setup package using the package wizard is where the problem comes in.

Installing this on another computer goes great. But when starting the application, it crashes and says it cannot find e:\shopkeeper\shopkeeper.mdb. How the heck can I fix this problem. I tried manually entering the database into the properties window like app.path & "\shopkeeper.mdb" and then it doens't work from the IDE.

Need some assistance on this one. couldn't find anything on mdsn or the internet for this.

I have one other problem, which might be easier to solve, so I'll save it for later.

Thanks guys - in advanced.


Old October 25th, 2006, 09:08 AM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

hi there..

you will have to provide the path to the datacontrol by code and then make the connection.


Old October 25th, 2006, 11:45 AM
Friend of Wrox
Join Date: May 2006
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts

You have several choices in how you can go about this.

The essential task is to dynamically set the DatabaseName property of the datacontrol in code.
Here is what it looks like "hard-coded" to a specific path, which isn't what you want:

Data1.DatabaseName = "e:\shopkeeper\shopkeeper.mdb"

What you need to do is either install the database in some path that you know ahead of time and can hard code into your app, or allow the user to set the path either during the setup process or directly from your application. When a path is entered by the you can store that path in the registry, or in a configuration or ini file of some type that your application is aware of and knows how to access to get the path.

So... lets say you write a function called GetDbPath which returns the path entered by the user. The your code would look something like this:

Data1.DatabaseName = GetDbPath & "\shopkeeper.mdb"

The call to refresh is needed when you are setting properties in code, as this refetches the recrodset.

Woody Z http://www.learntoprogramnow.com

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with path for loading Pics (app.path) Tabbasum Beginning VB 6 2 November 15th, 2007 04:57 AM
Implementing the all-path shortest path problem bitwords XSLT 1 December 6th, 2006 11:37 AM
DLLs and App.Path Jstmehr4u3 Pro VB 6 1 June 24th, 2003 03:35 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.