473,385 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Relative paths in VB

Hi, is it possible to use a relative path in a Connection
string to access an Access database in a stand alone
visual basic desktop application. All the examples that I
have seen have absolute paths but my application could be
a lot more flexible if it didn't depend on this.

Thanks,

Daniel Serrano
Nov 20 '05 #1
8 3431
* "Daniel Serrano" <an*******@discussions.microsoft.com> scripsit:
Hi, is it possible to use a relative path in a Connection
string to access an Access database in a stand alone
visual basic desktop application. All the examples that I
have seen have absolute paths but my application could be
a lot more flexible if it didn't depend on this.


Why not get the application's path and concatenate the full path of the
database?

<http://groups.google.com/groups?selm=uqB7aj0zDHA.3416%40tk2msftngp13.phx.gb l>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
"Daniel Serrano" <an*******@discussions.microsoft.com> schrieb
Hi, is it possible to use a relative path in a Connection
string to access an Access database in a stand alone
visual basic desktop application. All the examples that I
have seen have absolute paths but my application could be
a lot more flexible if it didn't depend on this.


Relative to what? You can use a relative path but it would be relative to
the current directory, so you would have to set the current directory first.
Both steps lead to an absolute path, so specifying the absolute path when
opening the connection is easier. You can use Sytem.IO.path.combine to build
an absolute path string.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
Cor
Hi Daniel,

If you use the wizards, I was always thinking it is imposible, but maybe you
can but I did not see that until now here and I am not using them, so
finding that out has for me a low priority.

But I think that if you do that you can for the same sake not use the wizard
at all.

If you do not use the wizard it is very easy to do.

The resource kit uses samples without the wizard.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir
I hope this helps a little bit?

Cor
Hi, is it possible to use a relative path in a Connection
string to access an Access database in a stand alone
visual basic desktop application. All the examples that I
have seen have absolute paths but my application could be
a lot more flexible if it didn't depend on this.

Nov 20 '05 #4
HI Cor and Daniel,

databasepath is the string of the database location. Now all you have to do
is store that location in an XML file and you are all set.

Please let me know if this helps.

Dim sConn As New OleDb.OleDbConnection
sConn.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Jet OLEDB:Database Password=;Data Source=" &
databasepath & _
";Password=;Jet OLEDB:Engine T" & _
"ype=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0" ";Je" & _
"t OLEDB:System database=;Jet OLEDB:SFP=False;Extended
Properties=;Mode=Share Den" & _
"y None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;J" & _
"et OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact
Without Replica Re" & _
"pair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"

"Cor" <no*@non.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
Hi Daniel,

If you use the wizards, I was always thinking it is imposible, but maybe you can but I did not see that until now here and I am not using them, so
finding that out has for me a low priority.

But I think that if you do that you can for the same sake not use the wizard at all.

If you do not use the wizard it is very easy to do.

The resource kit uses samples without the wizard.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir
I hope this helps a little bit?

Cor
Hi, is it possible to use a relative path in a Connection
string to access an Access database in a stand alone
visual basic desktop application. All the examples that I
have seen have absolute paths but my application could be
a lot more flexible if it didn't depend on this.


Nov 20 '05 #5
Cor
Hi Scorpion,

Please show us a sample using the OledBdataadapter Wizard from the designer
and than change the connection string.

(With of course less code than that you make a total connection, a dataset,
and a dataadapter.fill)

(For that I need 4 lines)

:-)

Cor
Nov 20 '05 #6
Hi Cor,

It is pretty simple really. I am not the best at explaining things
sometimes. If this does not work let me know and I will try again. Others
feel free to jump in if you understand where I am going.

Make your adapter in the wizard and point to a database on your hard drive
and it automatically generates

"OleDbConnection1"

We don't care about that.

All we want to do is change the connection string.

The object is there. We are just modifying the string it is using.

So we address the string in the code. Copying and pasting the code I used
before will reflect the new database location if you have used
"databasepath" as a string.

You can also create a class and use shared properties so you won't have to
do this again throughout the rest of your project.
"Cor" <no*@non.com> wrote in message
news:OM**************@TK2MSFTNGP11.phx.gbl...
Hi Scorpion,

Please show us a sample using the OledBdataadapter Wizard from the designer and than change the connection string.

(With of course less code than that you make a total connection, a dataset, and a dataadapter.fill)

(For that I need 4 lines)

:-)

Cor

Nov 20 '05 #7
Cor
Hi Scorpion,

You are right,

I checked it, I do not know why it never would work in past.
If you do this in the load event while you are using the designer for the
datadapter and for the binding

SqlConnection1.ConnectionString = connectionstring
SqlDataAdapter1.Fill(DataSet11)

It works normal.

I do not know why I never saw this simple sample in this newsgroups
(In past I have asked this question several times in this newsgroup and did
never got an answer. That was the reason I started to make the connections
by hand)

But it is so simple.

Thanks for your persistancy again.

This was always a question for myself, strange I never found it.

Cor

Nov 20 '05 #8
for future use.......

http://www.kjmsolutions.com/flexible...tionstring.htm
"scorpion53061" <Its the end of the world as we know it@here.com> wrote in
message news:uD**************@TK2MSFTNGP11.phx.gbl...
HI Cor and Daniel,

databasepath is the string of the database location. Now all you have to do is store that location in an XML file and you are all set.

Please let me know if this helps.

Dim sConn As New OleDb.OleDbConnection
sConn.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet
OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Jet OLEDB:Database Password=;Data Source=" &
databasepath & _
";Password=;Jet OLEDB:Engine T" & _
"ype=5;Jet OLEDB:Global Bulk
Transactions=1;Provider=""Microsoft.Jet.OLEDB.4.0" ";Je" & _
"t OLEDB:System database=;Jet OLEDB:SFP=False;Extended
Properties=;Mode=Share Den" & _
"y None;Jet OLEDB:New Database Password=;Jet OLEDB:Create System
Database=False;J" & _
"et OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact
Without Replica Re" & _
"pair=False;User ID=Admin;Jet OLEDB:Encrypt Database=False"

"Cor" <no*@non.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
Hi Daniel,

If you use the wizards, I was always thinking it is imposible, but maybe

you
can but I did not see that until now here and I am not using them, so
finding that out has for me a low priority.

But I think that if you do that you can for the same sake not use the

wizard
at all.

If you do not use the wizard it is very easy to do.

The resource kit uses samples without the wizard.

http://msdn.microsoft.com/vbasic/vbrkit/default.aspx

And if you have problems installing it

http://msdn.microsoft.com/vbasic/vbr...q/#installvdir
I hope this helps a little bit?

Cor
Hi, is it possible to use a relative path in a Connection
string to access an Access database in a stand alone
visual basic desktop application. All the examples that I
have seen have absolute paths but my application could be
a lot more flexible if it didn't depend on this.



Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Doug | last post by:
If I were to write an include with a relative path like include("../conf/config.php"); What is the use? As far as I understand it, the path is relative to the first script that is called by...
7
by: mark | last post by:
I am designing a website at the moment and looking at the difference between relative and absolute url links which is driving me crazy! I would like to use relative paths, but it is proving very...
5
by: jason | last post by:
Can anyone help me find a solution to quickly working out relative paths to a folder in the root of my server... Although it easy when you go - say - two levels down: .../includes it...
7
by: jason | last post by:
I am getting twisted by the possibility that my virtual includes which currently work great on non-domain remote IP will crash if I purchase a domain and point it to one of my designated...
2
by: Joe | last post by:
Hi, can someone tell me how to set up relativ paths in VS2003 C++ ? I have some source with a tree directory structure that segments include files in various directories: #include...
2
by: Alex | last post by:
Hi. I need some help on this. I have a user control (a header) in my root directory, and all my pages use that control. Then a created a folder (in my root directory) and put a new page inside it,...
8
by: JJ | last post by:
I'm confused about paths. I have a functionn that uses the mappath method, which I think requires a virtual path (is that the same as a relative path?). But this doesn't always work as the...
15
by: Lars Eighner | last post by:
Aside from the deaths of a few extra electrons to spell out the whole root relative path, is there any down side? It seems to me that theoretically it shouldn't make any difference, and it would...
2
by: BD | last post by:
Hi there. Using 8.2 on Windows. I have a situation where I have a db backup, which I want to deploy to a group of developer workstations. The target directory for the database files will be...
2
by: Peted | last post by:
Hi i have a circumstance where a user unzips a file, with a certain layer of directories to get to a textfile. So in any directory on the HDD they may end up with something like ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.