473,569 Members | 3,054 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 1926
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********@hot mail.com> wrote in message
news:EbNGe.2002 64$_o.72720@att bi_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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=c:\somep ath\myDb.mdb;"

If using a Workgroup (System Database)

oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"
& _
"Jet OLEDB:System Database=MySyst em.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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"
& _
"Jet OLEDB:Database Password=MyDbPa ssword", _
"myUsername ", "myPassword "
If want to open up the MDB exclusively

oConn.Mode = adModeShareExcl usive
oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=c:\somep ath\myDb.mdb;"

If using a Workgroup (System Database)

oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"
& _
"Jet OLEDB:System Database=MySyst em.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=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\somepath\mydb .mdb;"
& _
"Jet OLEDB:Database Password=MyDbPa ssword", _
"myUsername ", "myPassword "
If want to open up the MDB exclusively

oConn.Mode = adModeShareExcl usive
oConn.Open "Provider=Micro soft.Jet.OLEDB. 4.0;" & _
"Data Source=" & Application.Sta rtup & "\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********@hot mail.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.Sta rtupPath.
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
2150
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 appropriate error message, but if g_strDbPath is blank then the catch block throws an error saying “No error information available:...
1
7221
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#" %> <%@ import Namespace="System.Data" %> <%@ import Namespace="System.Data.OleDb" %> <script runat="server">
1
6916
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 needed. The Database is MS Access. Connection String:
0
1933
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 DataSet, it is trimming the trailing spaces. Anybody know why? Here is my code: System.Data.OleDb.OleDbConnection connection = null;
0
1290
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 error' message and the site becomes unusable. I have customErrors set to 'Off' so I can see what bit of code it is crashing at and it is always at...
2
2857
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 error' message and the site becomes unusable. I have customErrors set to 'Off' so I can see what bit of code it is crashing at and it is always at...
0
1109
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 "OleDbConnection undeclared identifier Please help, thanks using namespace System using namespace System::Data
1
1959
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 OleDbConnection(ConnectionString); theConn.Open(); OleDbCommand cmd = new OleDbCommand(theSQL, theConn);
3
1787
by: Ludvig | last post by:
This Exception is executed when using SQLConnection. OleDbConnection connects fine. System.EnterpriseServices.Platform.Initialize() +503 System.EnterpriseServices.ResourcePool..ctor(TransactionEndDelegate cb) +11 System.Data.SqlClient.ConnectionPool..ctor(DefaultPoolControl ctrl) +797...
1
1229
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), Friday char(5))"), tableName); OleDbConnection conn = new OleDbConnection(Form1.ConnectionString); ...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7619
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2118
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 we have to send another system
1
1229
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.