Picking up path name of Access Database 
Author Message
 Picking up path name of Access Database

I am trying to get my VB5 application to pick up an Access 97 database using
DAO and the OpenDatabase connection.
The 'test.mdb' database resides in the same directory as the VB application.
I do not want to hardcode the path name into the application .
I thought that if no path was specified for the Access database then the
path of the directory where the VB application resides would be used as the
default path.
However even though the Access database resides in the same directory as the
VB5 application an error was returned telling me that the database could not
be found is returned.
Example :
dim cnn1 as database

set cnn1 = OpenDatabase("test.mdb")

Is there anyway the database path can be picked up without hardcoding the
full path name

Regards

Richard McKenna



Sat, 20 Oct 2001 03:00:00 GMT  
 Picking up path name of Access Database
If it's in the same folder as the App, use

set cnn1 = OpenDatabase(App.Path & "test.mdb")

(actually, IIRC, you'll need to do some futzing around with it: there
are some cases where Path doesn't have the slash)

Quote:

> I am trying to get my VB5 application to pick up an Access 97 database using
> DAO and the OpenDatabase connection.
> The 'test.mdb' database resides in the same directory as the VB application.
> I do not want to hardcode the path name into the application .
> I thought that if no path was specified for the Access database then the
> path of the directory where the VB application resides would be used as the
> default path.
> However even though the Access database resides in the same directory as the
> VB5 application an error was returned telling me that the database could not
> be found is returned.
> Example :
> dim cnn1 as database

> set cnn1 = OpenDatabase("test.mdb")

> Is there anyway the database path can be picked up without hardcoding the
> full path name

> Regards

> Richard McKenna

--

Beer, Wine and Database Programming.  What could be better?
Visit "Doug Steele's Beer and Programming Emporium"
http://webhome.idirect.com/~djsteele/



Sat, 20 Oct 2001 03:00:00 GMT  
 Picking up path name of Access Database
I've had the same problem here. My app worked fine at runtime (not
specifiying a path), but during design time it would not find my
database even though it was in the same directory as my app. It seems
that VB wanted to search for it in my "c:\Program Files\Microsoft Visual
Studio\Vb98\*.mdb" directory and NOT in my project directory. So I
simply moved a copy of my database there for design time, and it seemed
to find it fine.


Sun, 04 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Help: How to use common dialog box to pick a path name

2. Utility to pick pictures into Access database and save its as file

3. Accessing Data in Multivalue database (like PICK)

4. Accessing Data in Multivalue database (like PICK)

5. Accessing Data in Multivalue database (like PICK)

6. Retrieving Full Database Path Name

7. Current database path name

8. Path names in a database problem

9. Set Database Name property using no path

10. Passing Database name and path

11. Set Database name using no path

12. Help:Common dialog Box to Pick Path only??

 

 
Powered by phpBB® Forum Software