Oledb Connection String ?

M

Mark Gaeth

Greetings,

I have tried for an answer on another forum with no direct answer. I have my
forms that have a connection to an Access db with all the connections
created by the wizard. No problems with the operations of the forms in the
design environment / machine. However, when I deploy the program I will not
have control over the connection string. I have used Application.StartUpPath
for the record source of the Crystal Reports but I want to use the same
style for the connection.string. Can and how is this be done?

Can I insert this function call in the connection string? For example:

The current string:
Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet
OLEDB:Database Locking Mode=0;Data Source="C:\Documents and Settings\Mark
Gaeth\My Documents\Visual Studio Projects\My Model Railroad
Empire\bin\MyRRDBXP.mdb";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;persist security info=False;Extended
Properties=;Mode=Share Deny None;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

Proposed String:

Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet
OLEDB:Database Locking Mode=0;Data Source=Application.StartUpPath() &
"\MyRRDBXP.mdb";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;persist security info=False;Extended
Properties=;Mode=Share Deny None;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
I am using VB.Net from VS2003. Thank you for any assistance you can throw my
way.

Mark Gaeth
Decatur, IN
 
C

Cor Ligthert

Mark,

You can set your connectionstring at any moment before the open of a
connection by
oledbconnection.connectionstring = "blabla"

When you use the designer don't than change any of your connectionstring
code in that part, that can give problems when you are updating your program
using the desinger.

With this command above you just overwrite it.

I hope this helps,

Cor
 
P

Paul Clement

¤ Greetings,
¤
¤ I have tried for an answer on another forum with no direct answer. I have my
¤ forms that have a connection to an Access db with all the connections
¤ created by the wizard. No problems with the operations of the forms in the
¤ design environment / machine. However, when I deploy the program I will not
¤ have control over the connection string. I have used Application.StartUpPath
¤ for the record source of the Crystal Reports but I want to use the same
¤ style for the connection.string. Can and how is this be done?
¤
¤ Can I insert this function call in the connection string? For example:
¤
¤ The current string:
¤ Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet
¤ OLEDB:Database Locking Mode=0;Data Source="C:\Documents and Settings\Mark
¤ Gaeth\My Documents\Visual Studio Projects\My Model Railroad
¤ Empire\bin\MyRRDBXP.mdb";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;persist security info=False;Extended
¤ Properties=;Mode=Share Deny None;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
¤
¤ Proposed String:
¤
¤ Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet
¤ OLEDB:Database Locking Mode=0;Data Source=Application.StartUpPath() &
¤ "\MyRRDBXP.mdb";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;persist security info=False;Extended
¤ Properties=;Mode=Share Deny None;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
¤ I am using VB.Net from VS2003. Thank you for any assistance you can throw my
¤ way.

As Cor mentioned to can set the ConnectionString property at run time.

BTW, you may want to pair down your connection string a bit. Most of those
parameters are not required unless they're being changed from their default
values:

ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0"; & _
"Data Source=" & Application.StartUpPath() & _
"\MyRRDBXP.mdb";

Paul
~~~~
Microsoft MVP (Visual Basic)
 
M

Mark Gaeth

Thanks for the tip. I did pare down the string and it did not crash in on
the design machine! Yippy-Skippy. I will try a deployment this weekend and
see it if works on a neutral machine.

Thanks again and will update as to the results after this weekend.

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top