I have written a Windows application in Visual Studio that reads data from a Microsoft Access database. Everything works fine; however, after publishing the application I need it to read the database when the database is changed or updated. Can anyone help with where to put the Access database and how to get the application to look at it when it opens?
Asked
Active
Viewed 174 times
0
-
You've used Visual Studio, but **what language** in Visual Studio is the program you wrote? – Wai Ha Lee Jan 20 '19 at 18:50
-
not only that but on what are you publishing it? – markorial Jan 20 '19 at 19:47
-
The program is written in VB code – user2062689 Jan 21 '19 at 20:41
-
I'm really struggling with filesystemwatcher. I use a Public Class called DBControl that sets up the DB connection Private DBCon As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=Phase10.accdb;") – user2062689 Jan 22 '19 at 10:55
1 Answers
0
It sounds to me like you can place the Microsoft Access (presumably, a single .accdb file) anywhere you want to put it and then--as long as your program knows where that file is--simply use System.IO.FileSystemWatcher.
See this question/answer(s) for more details: Notification when a file changes?

Jazimov
- 12,626
- 9
- 52
- 59
-
I'm really struggling with filesystemwatcher. I use a Public Class called DBControl that sets up the DB connection Private DBCon As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=Phase10.accdb;"). So how do I create a situation where the program always looks at the most recent version of the db? – user2062689 Jan 22 '19 at 10:59
-
I think I might have misunderstood your requirement based on the way you asked your question. When you connect to a database as you describe, you already can read any changes/updates to that database. That's how databases work. If you're saying that you have multiple copies of the Phase10.accdb database file and you want to monitor which of those is the most current, then you can use FileSystemWatcher. Please edit your question for clarity. – Jazimov Jan 22 '19 at 15:02
-
Apologies if the question was unclear. As a novice to vb.net and Visual Studio I find the whole connection process confusing. My DBControl class makes the connection to the database, but when I look at the files I find the database in C:\ VB folder; C:\VB\MWPhillips folder; C:\VB\MWPhillips\MyProject folder; C:\VB\MWPhillips\Bin\Debug folder as well as C:\VB\MWPhillips\Bin\Debug\MyProject folder. Which one is the program actually looking at? – user2062689 Jan 23 '19 at 18:30