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

Setting Oledbconnection datasouce path

P: n/a

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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a

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

P: n/a
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

P: n/a

"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

P: n/a

"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 discussion thread is closed

Replies have been disabled for this discussion.