Trouble locating database in depolyed application

  • Thread starter Thread starter David
  • Start date Start date
D

David

Hi, I have an application that connectes using oledb connection to an access
database.

The program works fine in debug and release mode on the developement machine
but cannot locate the database file on another machine when I deploy the
application.

In code, I am using the following lines to make the connection...

temp = System.Windows.Forms.Application.ExecutablePath & "\Datalog.mdb"

Dim myconnection As New
OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source = " & temp)

I tried "StartupPath" also but same problem. On the target machine,the
exception indicates it is looking for the original path from the development
machine and not looking in the application's installed path.

Any help please will be much appreciated.

Thanks
 
Hi David,

You did probably use the designer to make the connection. Than you have to
use that same connection and it becomes.

temp = System.Windows.Forms.Application.ExecutablePath & "\Datalog.mdb"
usedConnection.connectionstring =
OleDbConnection("Provider=Microsoft.jet.oledb.4.0;Data Source = " & temp)

I hope this helps?

Cor
 
Cor,

I tried as you suggested but usedconnection was not a valid object ??

The version of VB.NET is 2003, should it be something like
system.forms.usedconnection ??

Also, upon closer inspection of my code, I found it was actually opening the
database ok but the problem actually occuredd when I tried to fill a
datagrid with a dataset. The dataset was created by dragging the table from
the Server Explorer, I expect that it has set up a fixed path to the table
somewhere. Could I establish the dataset manually so that I can point the
program to the startup directory ??

Thanks
 
Hi David,

With usedConnection I mean the connection that you are using, that you can
see in the connection that is on your form down in the left mostly when you
do not drag them away,

If you use a conn.open than the name is that first name.

:-)

Cor
 
Back
Top