Connection String

A

Arif Çimen

Hi to everyone,

I created a Access Database (*.mdb) file.

I configured the connection string on the Server Exploer.

My problem is that this conncetion string has a path pointing to mdb file.
But after installing the application to the target machine, the path in the
connection string is invalid.

for Example:

my mdb file path is this on my machine
f:\folder\database.mdb

And the folder may be on the target machine is:

c:\program files\...\database.mdb

How can I deal with this problem.

Thanks for any help.

Arif Çimen.
 
A

Alan Baljeu

Hi to everyone,
I created a Access Database (*.mdb) file.

I configured the connection string on the Server Exploer.

My problem is that this conncetion string has a path pointing to mdb file.
But after installing the application to the target machine, the path in the
connection string is invalid.

for Example:

my mdb file path is this on my machine
f:\folder\database.mdb

And the folder may be on the target machine is:

c:\program files\...\database.mdb

How can I deal with this problem.

Thanks for any help.

Arif Çimen.

Arif, you probably should set the connection string in the source code.

string TEMPLATE = "gobbledygook={0}";
string path = "f:\folder\database.mdb";
string conn_string = string.Format(TEMPLATE, path);
mConn.ConnectionString = conn_string;

Only you know what TEMPLATE should be and how to calculate path.
TEMPLATE should be like what you already configured, but replace the explicit path with
{0}.

Alan
 
O

Otis Mukinfus

Hi to everyone,

I created a Access Database (*.mdb) file.

I configured the connection string on the Server Exploer.

My problem is that this conncetion string has a path pointing to mdb file.
But after installing the application to the target machine, the path in the
connection string is invalid.

for Example:

my mdb file path is this on my machine
f:\folder\database.mdb

And the folder may be on the target machine is:

c:\program files\...\database.mdb

How can I deal with this problem.

Thanks for any help.

Arif Çimen.

Use your application config file to store the connection string. When you are
developing set the app config connection string to the development location.
When you distribute the application make sure the app config points to the
production location.

In your application code retrieve the connection string from the config file.

If you want to learn the details of what I am saying, read the help files
regarding configuration files.

Otis Mukinfus
http://www.otismukinfus.com
 

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