Moon
Moon

Reputation: 11

Access database is not a valid path

I have build a VB project to a setup installer and I have Access database in it. I have already attached the access file in my setup. However, when i try to install my project to other computer to let other users use, this happens:

image

Sorry for the red-coloured sketch. It is my Laptop's name. How to solve this problem, anyone?

I have search some solutions, some say to change to UNC path. Some say to use linked table manager. But I cannot use linked table manager as I imported my Excel file to Access.

Anyone can help me?

Thanks!

https://i.sstatic.net/q30kX.png

EDIT: I have placed the Access Database file in my setup installer.

Upvotes: 0

Views: 5436

Answers (4)

ashan
ashan

Reputation: 57

if you are not using connection class Dim provider As String = "provider=Microsoft.ACE.OLEDB.12.0;data source=|DataDirectory|" Dim database As String = "orsa.accdb" Dim connstring As String = provider & database

put your database in to bin directry in your application and then recreate exe

Upvotes: 0

Hans
Hans

Reputation: 382

Your program try to access a database on the current disk where the program is installed. But this path doesn't exists. You should try to provide a dynamic file path? Or you can also add your database to the embedded ressources and then pick out it from the ressources to an existing folder (the assembly executing path for exemple).

Upvotes: 0

Malcolm Salvador
Malcolm Salvador

Reputation: 1566

You are experiencing said error because your db. file path is not valid in the client unit. Perform the following

  1. Change the location of your access database. Place it next to the .exe of your Solution
  2. Depending on how you set up your connection to the database, change the connection string to simply the name of your access file (ie : C:\Users\asasdas\orsa.accdb to simply orsa.accdb

Upvotes: 0

Joel Coehoorn
Joel Coehoorn

Reputation: 416121

You need to change the connection string. It has an absolute path looking in your Documents folder. You should add the database to the solution in Visual Studio, set the installer to deploy the database file o the AppData folder, and change the connection string to look in that path.

Upvotes: 1

Related Questions