0

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?

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
user2062689
  • 9
  • 1
  • 2

1 Answers1

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