Click here to Skip to main content
15,745,005 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have developed a transport ticketing system using Visual C#2008 Express as front end and Microsoft Access 2010 as back end.
The application works fine on the development PC storing all data currently on the Access database and prints a reciept eventually but my problem is how to run this application successfully on another computer with the database functioning normally as it works on the development PC.

After publishing and deploying the application to another computer upon running the application, it throws an error indicating that the database path cannot be found.

I need serious help as regard resolving this issue.

What I have tried:

connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\MY CLASS\Downloads\good work\new work\MDIFORM\busdata.accdb;
            Persist Security Info=False;";
Updated 13-Apr-23 0:04am
murkalkiran 4-May-16 4:39am    
Install your application in give path it may work for you

You need to make sure that the database is copied into the appropriate folder.

If you have included the database in your Visual Studio project (i.e. it is visible in Solution Explorer) then you can click on the file, go to the Properties window and change the setting for Copy to Output Directory to "Copy Always".

That way the database will be deployed as part of your project.

Alternatively copy the file as a step in your deployment script - you may need to create the folder on the target PC. To make this easier move your connection string to the App.Config file (and make sure that is Copy Always too)

Alternatively, store the database on a network drive that the target PC is connected to (not recommended with Access however)
Share this answer
Unless your application installs the database to that specific location - which is both unlikely and not a good idea - it will fail to find the database file. If it tries, there is a very good chance that it won;t be allowed to find it as the User your app is being executed by is unlikely to automatically have permission to access the folder (unless his username happens to be "MY CLASS"
See here: Where should I store my data?[^] - it suggests some much better places to keep it, and shows how to access them!
Share this answer
CHill60 4-May-16 4:55am    
5'd. Good spot on the username - I stopped reading the connection string once I realised it was hard-coded :blush:
Looks like you skipped the lesson on "networked apps and databases".

Your problem is that you hard coded the database path to local disk of development PC.
Database must be on server.
Share this answer
"C:\Users\MY CLASS\Downloads\good work\new work\MDIFORM"

replace the above path with |DataDirectory| in all forms in your project.

Check below.
connection.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\busdata.accdb;
Persist Security Info=False;";
Share this answer
Richard MacCutchan 13-Apr-23 6:51am    
The question was answered seven years ago, and your suggestion will not help unless the database is copied to the correct location on the alternate system.
Richard Deeming 13-Apr-23 6:53am    
Aside from the fact that you're seven years late to this question, you've ignored the valid concerns raised in solution 2: if the application is installed in the Program Files directory, then the user won't have access to update a database stored in the application directory. It needs to be stored somewhere that the user can write to.

And also solution 3: unless it's a single-user application, the database needs to be stored on the server.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900