Dynamics MS Access Connection (1 Viewer)

Cancer69

New member
Local time
Today, 22:04
Joined
May 18, 2015
Messages
2
Hello everyone. I'm newbie here in the forum. This is my first thread.

I am using the following codes to connect to MS Access database using vb.net code. I am providing the file path name and directory. This codes work fine in my computer. How can I make this codes as dynamics connection that can run to another computer that no need to change the path. I'm using MS Access 2013 and Visual Studio 2008 (VB.NET). Below is the connection string code i used to connect to database in VB.NET form. So, how and what is the connection string I will be going to use in my form. Thank you very much.

below is my hard coded connection string which is working file.


Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString =
"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\JV\Desktop\MyVBProject\FeedBackSystem\KPI.accdb"

Then I change to this code and I'm getting error. It say "Could not find the file. C:\Users\JV\Desktop\MyVBProject\FeedBackSystem\bin\x86\Debug\KPI.accdb"


Dim conn As New System.Data.OleDb.OleDbConnection()
conn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source= |DataDirectory|\KPI.accdb"



 

Ranman256

Well-known member
Local time
Today, 10:04
Joined
Apr 9, 2015
Messages
4,339
Can you not just LINK the tables using this connection, and forgo any VB code?
 

Cancer69

New member
Local time
Today, 22:04
Joined
May 18, 2015
Messages
2
Anybody can give an idea on how to fix this issue. Also, I'm bothering me. I am testing my application and the database access is stored in bin/x86/Debug folder, why it is the below path was not access instead. How could I check to validate the actual path where the application finding the DB.

C:\Users\JV\Desktop\FeedBackSystem\FBSystems\KPI.accdb
 

Users who are viewing this thread

Top Bottom