By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,773 Members | 911 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,773 IT Pros & Developers. It's quick & easy.

OLEDBConnection

P: n/a
Is there a way to make the OLEDBConnection to my Access file relative to the
path of the executable of the file? I work on the program on a lot of
different computers and I am tired of having to copy things around so that
the Access file is in the right path.

Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies

P: n/a
As a follow up, is there then a safe way to change what ever I need to
change so that my data adapter, dataset and data bindings don't get
completely screwed up.
"David A. Osborn" <do********@hotmail.com> wrote in message
news:EbNGe.200264$_o.72720@attbi_s71...
Is there a way to make the OLEDBConnection to my Access file relative to
the path of the executable of the file? I work on the program on a lot of
different computers and I am tired of having to copy things around so that
the Access file is in the right path.


Nov 21 '05 #2

P: n/a
David A. Osborn wrote:
Is there a way to make the OLEDBConnection to my Access file relative to the
path of the executable of the file? I work on the program on a lot of
different computers and I am tired of having to copy things around so that
the Access file is in the right path.


For standard security

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;"

If using a Workgroup (System Database)

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"
& _
"Jet OLEDB:System Database=MySystem.mdw", _
"myUsername", "myPassword"

Note, remember to convert both the MDB and the MDW to the 4.0
database format when using the 4.0 OLE DB Provider.
If MDB has a database password

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"
& _
"Jet OLEDB:Database Password=MyDbPassword", _
"myUsername", "myPassword"
If want to open up the MDB exclusively

oConn.Mode = adModeShareExclusive
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"

Nov 21 '05 #3

P: n/a
I was confused by your comment;
"Note, remember to convert both the MDB and the MDW to the 4.0
database format when using the 4.0 OLE DB Provider"
I use an Access Database (.mdb extension) but was not aware of the mdw
extension nor the nead to convert to anything. I also use the 4.0 OLE DB
Provider and haven't had to convert anything.

Could you explain a bit more...thanks for you comments.
--
Dennis in Houston
"Chris" wrote:
David A. Osborn wrote:
Is there a way to make the OLEDBConnection to my Access file relative to the
path of the executable of the file? I work on the program on a lot of
different computers and I am tired of having to copy things around so that
the Access file is in the right path.


For standard security

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\somepath\myDb.mdb;"

If using a Workgroup (System Database)

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"
& _
"Jet OLEDB:System Database=MySystem.mdw", _
"myUsername", "myPassword"

Note, remember to convert both the MDB and the MDW to the 4.0
database format when using the 4.0 OLE DB Provider.
If MDB has a database password

oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"
& _
"Jet OLEDB:Database Password=MyDbPassword", _
"myUsername", "myPassword"
If want to open up the MDB exclusively

oConn.Mode = adModeShareExclusive
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & Application.Startup & "\somepath\mydb.mdb;"

Nov 21 '05 #4

P: n/a
David,

Probably you use a dragged connection.

Than just set the connection in by instance the form load of your program,
however before the open of the connection.

Don't delete the dragged connection from the designer part, because that can
give you all kind of trouble.

Connection1 = New Connection(And than the connection string you want)

That string you can save in an XML or Ini or whatever file.

I hope this helps,

Cor
Nov 21 '05 #5

P: n/a
On Sat, 30 Jul 2005 15:40:20 GMT, "David A. Osborn" <do********@hotmail.com> wrote:

Is there a way to make the OLEDBConnection to my Access file relative to the
path of the executable of the file? I work on the program on a lot of
different computers and I am tired of having to copy things around so that
the Access file is in the right path.



There are a few ways to fetch the application path one of which is Application.StartupPath.
Paul
~~~~
Microsoft MVP (Visual Basic)
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.