473,506 Members | 17,176 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OLEDBConnection

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
5 1922
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2136
by: Job Lot | last post by:
I have written the following function which returns OleDbConnection object. If global variable g_strDbPath contains an invalid file name or path name the catch block throws an error with...
1
7215
by: Lilly | last post by:
Hi all. I'm really sorry for this post, I'm sure most of you will think it's a silly question, but the following doesn't work and I'm really new to ASP.NET: <%@ Page Language="C#" %> <%@...
1
6910
by: Matthias Kwiedor | last post by:
Hello! My Application is Multi-Threaded, where i have several threads which get datas and write them to the database, or have to read from the database to compare the datas and make updates if...
0
1930
by: Seth | last post by:
First off, my apologies if this is in the wrong newsgroup, but I hope I'm close enough. I'm trying to do some parsing of a CSV file using OleDbConnection, but for some reason, when I populate my...
0
1286
by: Grant | last post by:
My C# web application connects to an Access database using the OleDbConnection and OleDbDataReader. I have 3 other computers that connect to this server but very frequently I get an 'Unspecified...
2
2847
by: Grant | last post by:
My C# web application connects to an Access database using the OleDbConnection and OleDbDataReader. I have 3 other computers that connect to this server but very frequently I get an 'Unspecified...
0
1108
by: Tim | last post by:
I work on a dll with mfc support in C++ .NET. I include the following statemwents, but the complier does not allow me to do OleDbConnection * cnNwind = new OleDbConnection() The error msg says...
1
1951
by: Keith | last post by:
Hi, if have this method in a cs file that connections to a database and returns a datareader to my web form. public OleDbDataReader GetDataReader(string theSQL) { theConn = new...
3
1783
by: Ludvig | last post by:
This Exception is executed when using SQLConnection. OleDbConnection connects fine. System.EnterpriseServices.Platform.Initialize() +503...
1
1222
by: Souloron | last post by:
Here what I did: string cmdText = String.Format(("CREATE TABLE {0} (dno int primary key, Sunday char(5), Monday char(5), Tuesday char(5), Wednesday char(5), Thursday char(5),...
0
7103
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7370
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7021
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5035
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4701
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1532
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
409
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.