creating an vb.net exe

B

Beski

I have created a vb.net program that incorporates a SQL Sever Database.
In my program I have the line:

con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source =
database.mdb"

So I used the vb.net publish project tool and made an installation
package, but everytime that I install it on another PC I will get an
error that says it could not find the database. I looked into the
folder where it installed everything and found that it installed the
database in a different folder. When I copy the database to the proper
folder, it will work.

How do i set up the installation package to put the database in the
right folder? Or how can I change my code that it will work on other
computers after it had been installed, and the database is in a
different folder?

Thanks for the help


Beski
 
C

Cowboy \(Gregory A. Beamer\)

There are a few ways of solving this.

What you have right now is the debug version pointing back to the directory
the MDB is installed in, which is a directory other than the /bin folder.
When you install, it is most likely installing to /bin.

How to solve:
1. Put the connection string in a config at install time with a custom
installer and set an absolute path to the directory. If you create the
installer project, you can set up a variable for the user to decide where to
put the database.

2. Copy the MDB to the /bin using a pre or post compile step (in Visual
Studio .NET; either will work on this one*) and debug until you have the
connection string correct. Then, make sure the install puts everything in
one directory.

3. Hack with a custom installer until you set up the directories identical
to your current set up. This is the most painful and least ideal solution.

* To get to pre and post compile, right click the project and choose
properties. You can set up build properties using that tab.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 

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