Setting a relative DB location

Joined
Oct 20, 2006
Messages
21
Programming Experience
Beginner
I was wondering how you can set a relative DB location in vb 2005. Right now I have an exact location of


VB.NET:
MyCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\UNH\CS 623\projects\ASAP.mdb"

I would like to be able to trasport this aplication to other computers. If I do so this location will be incorrect. Is there a syntax I can use so it will look in a relative location?

I have a field in the datase which is the location for pictures. Can I also make those relivtive locations?

If I package this application how do I set it so that it will pull my database and pictures and put them so they are in the right relative locations?
 
Hi! I used this connectionString...
Public myConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\XPTO.mdb;Jet OLE" & _
"DB:Database Password=" + passwordbd
For the pictures i think the best is for you to make it like this: path="\images\imag1.jpg" this way will start form the application path.
 
Cool


If I use that connection string and place my database in the bin folder that seems to work. With the pictures I created a sub folder in the bin folder called images and put my images there. However in the access database I used this format .\images\image.jpg (I need the “.” First). That seems to work. Now my question is if I "Publish" the application how do I get it to incorporate those images and DB in the exe file that can be installed on any computer?
 
you must use the setup project in vb. there you can configure what you want/where to be installed in the customer computer (database, images, reports).
 
you must use the setup project in vb. there you can configure what you want/where to be installed in the customer computer (database, images, reports).

I added my database and all the pictures are resources to the project. When I publish the project it includes all the files. However when I run the application and it tries to access the database it says it cannot be found. I used + Application.StartupPath + and it works but the database it published to a different folder then the one that it is looking for. There is a folder called "ASAP.exe"... and one called "ASAP..tion". My program is looking in the exe tion folder but the dtabase is in the exe folder. However the image resourses are in both the exe and tion folders. What is up with that?
 
Back
Top