Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 25th, 2006, 12:51 AM
Registered User
Join Date: Oct 2006
Location: , , .
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.


Reply With Quote
  #2 (permalink)  
Old October 25th, 2006, 09:08 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
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.


Reply With Quote
  #3 (permalink)  
Old October 25th, 2006, 11:45 AM
Friend of Wrox
Join Date: May 2006
Location: San Diego, CA, USA.
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
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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

All times are GMT -4. The time now is 11:59 PM.

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