473,406 Members | 2,390 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,406 software developers and data experts.

Setting Oledbconnection datasouce path


I would like to set the DataSource path on my
Oledbconnection so that the Windows application will
always look in the place where the binary is stored when
it looks for the Access database file. How can this be
done?

I tried sticking the function CurDir() into the property
string but I don't seem to be getting the syntax right.
Here is the connection string that I am trying to modify.

====================

Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry
Path=;Jet OLEDB:Database Locking Mode=1;Jet
OLEDB:Database Password=;Data Source="C:\Documents and
Settings\Bob\My Documents\Visual Studio Projects\GoHands1
\GoHands1\bin\godanddeaf.mdb";Password=;Jet OLEDB:Engine
Type=5;Jet OLEDB:Global Bulk
Transactions=1;Provider="Microsoft.Jet.OLEDB.4.0"; Jet
OLEDB:System database=;Jet OLEDB:SFP=False;Extended
Properties=;Mode=Share Deny None;Jet OLEDB:New Database
Password=;Jet OLEDB:Create System Database=False;Jet
OLEDB:Don't Copy Locale on Compact=False;Jet
OLEDB:Compact Without Replica Repair=False;User
ID=Admin;Jet OLEDB:Encrypt Database=False
Nov 20 '05 #1
6 3512
Hi Bob,

You can create a new connection in your form load event, that works, I have
a long time searched for that however it is really that simple.

I hope this helps, if it is not clear be free to ask again?

Cor
Nov 20 '05 #2
See

http://www.kjmsolutions.com/flexible...tionstring.htm

I would like to set the DataSource path on my
Oledbconnection so that the Windows application will
always look in the place where the binary is stored when
it looks for the Access database file.

Nov 20 '05 #3

OK.

I tried putting the new connection in the Form Load event
but I still seem to not know how to properly write the
string with the Curdir() function embedded with in.
Still a novice at this programming stuff.

Here is what I tried and the resulting error...

Private Sub Form1_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyBase.Load

'OleDbConnection1
'
Me.OleDbConnection1.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=" + CurDir() + "\godanddeaf.mdb"";" & _
"Password=;Jet OLEDB:Engine Type=5;Jet
OLEDB:Global Bulk Transactions=1;Provider=" & _
"""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System
database=;Jet OLEDB:SFP=False;Extende" & _
"d Properties=;Mode=Share Deny None;Jet OLEDB:New
Database Password=;Jet OLEDB:Cr" & _
"eate System Database=False;Jet OLEDB:Don't Copy
Locale on Compact=False;Jet OLED" & _
"B:Compact Without Replica Repair=False;User
ID=Admin;Jet OLEDB:Encrypt Database=" & _
"False"

Error -
Additional information: Format of the initialization
string does not conform to specification starting at
index 263.


-----Original Message-----
Hi Bob,

You can create a new connection in your form load event, that works, I havea long time searched for that however it is really that simple.
I hope this helps, if it is not clear be free to ask again?
Cor
.

Nov 20 '05 #4
Hi Bob,

I assume that that long connection string is not needed, mostly this is
enough and than I initialize the connection as new however when I write this
now I am in doubt if it is necessary, however I always do it this way, maybe
only adding that connectionstring is enough, because logical it should be
that.

dim connString as string = Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\myaccessfile.mdb;
Oledbconnection1 = New OleDbConnection(connString)

I hope this helps?
Cor
I tried putting the new connection in the Form Load event
but I still seem to not know how to properly write the
string with the Curdir() function embedded with in.
Still a novice at this programming stuff.

Here is what I tried and the resulting error...

Private Sub Form1_Load(ByVal sender As Object, ByVal e
As System.EventArgs) Handles MyBase.Load

'OleDbConnection1
'
Me.OleDbConnection1.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=" + CurDir() + "\godanddeaf.mdb"";" & _
"Password=;Jet OLEDB:Engine Type=5;Jet
OLEDB:Global Bulk Transactions=1;Provider=" & _
"""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System
database=;Jet OLEDB:SFP=False;Extende" & _
"d Properties=;Mode=Share Deny None;Jet OLEDB:New
Database Password=;Jet OLEDB:Cr" & _
"eate System Database=False;Jet OLEDB:Don't Copy
Locale on Compact=False;Jet OLED" & _
"B:Compact Without Replica Repair=False;User
ID=Admin;Jet OLEDB:Encrypt Database=" & _
"False"

Error -
Additional information: Format of the initialization
string does not conform to specification starting at
index 263.


-----Original Message-----
Hi Bob,

You can create a new connection in your form load event,

that works, I have
a long time searched for that however it is really that

simple.

I hope this helps, if it is not clear be free to ask

again?

Cor
.

Nov 20 '05 #5

"Bob Achgill" <an*******@discussions.microsoft.com> wrote in message
news:11*****************************@phx.gbl...

OK.

I tried putting the new connection in the Form Load event
but I still seem to not know how to properly write the
string with the Curdir() function embedded with in.
Still a novice at this programming stuff.

Hello Bob,

In your form_load event change the datasource to just the name of your .mdb
file.

"Data Source = mydatabase.mdb"

There is no need to use the curdir() function just use the relative path in
the form load event.

HTH
Nov 20 '05 #6

"Bob Achgill" <an*******@discussions.microsoft.com> wrote in message
news:11*****************************@phx.gbl...

OK.

I tried putting the new connection in the Form Load event
but I still seem to not know how to properly write the
string with the Curdir() function embedded with in.
Still a novice at this programming stuff.

Hello Bob,

In your form_load event change the datasource to just the name of your .mdb
file.

"Data Source = mydatabase.mdb"

There is no need to use the curdir() function just use the relative path in
the form load event.

HTH
Nov 20 '05 #7

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

Similar topics

1
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...
5
by: Tim Bücker | last post by:
Hello. I am trying to get a connection to MySQL using OleDb but it seems that I am making something wrong. I´ve found this source in the net but it doesn´t work for me: ...
0
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...
3
by: COHENMARVIN | last post by:
I put the following code in my asp.net page: dbPath = MapPath("/FBDB/db1_newport2003.mdb") strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" strConnect = strConnect & "Data Source=" & dbpath & ";"...
5
by: David A. Osborn | last post by:
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...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
7
by: Miro | last post by:
I think i have found my problem following an example ive searched for on the net. I am using vb.net 2005 express. What I am looking for is a drag drop from the toolbar that is an...
2
by: Sin Jeong-hun | last post by:
Visual Studio automatically generates DateSet classes and all the other classes automatically at the design time. But is it possible to choose am MDB file at the rum time, and select a table to...
2
by: user | last post by:
Hi everyone, Im using the following conn string in asp.net 1.1 using vb.net: Dim conn As New OleDbConnection("Provider=MS Remote;Remote Server=http://myintranetserver/; Remote...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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
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...
0
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...

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.