Click here to Skip to main content
15,997,912 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
which path i am use in project

after depled my project that time software not found database file

What I have tried:

Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\sunil\hardware date.vb\hardware.vb\hardware.accdb")

Dim con As String = ("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= + Application.StartupPath + \..\hardware.accdb")
Posted
Updated 17-May-16 6:09am

1 solution

Assuming you've deployed the database file to the same folder as your application, use |DataDirectory| in your connection string to point to that directory:
VB.NET
Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\hardware.accdb")

However, if your application is installed under the "Program Files" folder, then it will not have permission to update the database file unless you run it elevated (right-click, "Run as administrator").
 
Share this answer
 

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