Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,I have this application I built with c# 4.0 .It connects to an access database and grab from table [ABC], populates a listbox and performs
some calculations and dumps the result in exel file .But I was wondering if there is way to do it every ten minutes or 5 minutes on a real time without me having to do any button click event? I am open to any idea, I don't just know how to get it going by its self doing all those actions.
Thanks.
Posted
Updated 17-Mar-15 2:25am
v2
Comments
Sergey Alexandrovich Kryukov 16-Mar-15 12:06pm    
There is no such thing as "real time" in such systems. You may want to be more accurate in terminology.
Is the Access usage itself a problem? Why Access, by the way?
—SA
Ekona_Pikin 16-Mar-15 12:20pm    
Access has been used as the DB in this case ,I was wondering if I could use c# to automate the process of pulling from the Access DB every so and so minutes and perform some calculations form and dump the results in an excel file, I have built this application, but the user would have to perform some click_events on WinForm.

Please see my past answer where I suggested to use my pattern, very reliable one: Polling Database with Timer[^].

See also, for some background, not necessarily very relevant, just good to understand: Application 'dashboard' for website accounts[^].

—SA
 
Share this answer
 
Comments
Ekona_Pikin 16-Mar-15 12:14pm    
Thanks SA, this just a standloen c# App would it possible to do something like this
with Acess DB?
Sergey Alexandrovich Kryukov 16-Mar-15 12:15pm    
I know and already answered. My advice is applicable.
—SA
Set up a BackgroundWorker and do the work in there. Then use the progress reporting mechanism to pass the new values to the UI thread via the event, and load the Listbox from that (if you really need the listbox). The thread then sleeps until the next time, and goes back round.

But it's not a nice way to do it - Access is not good at multiuser support at the best of times. If you can, use an SQL database, and if you are processing new or changed records only, set up an SQL Trigger to kick off the re-calculation instead of a timer: https://msdn.microsoft.com/en-us/library/938d9dz2.aspx[^]
 
Share this answer
 
Comments
Ekona_Pikin 16-Mar-15 12:13pm    
Thanks OriginaGriff, but this is just a stand alone c# Application and the database is Access is it possible my boss is on my neck, just want to see if there is better way I could just change to as suggested.
OriginalGriff 16-Mar-15 12:43pm    
Even if it's a stand-alone application, I assume there is some other app changing the Access DB? Or it wouldn't be worth re-calculating every ten minutes, would it?
If so, then you are still in a multi-user situation...
Ekona_Pikin 16-Mar-15 12:55pm    
Yes there is another app that adds data to the Access DB and mine wants to access the Data and display results with calculations.
OriginalGriff 16-Mar-15 13:05pm    
And that's the problem: if the two apps are trying to access the file at the same time, you have to be very, very careful: Access is really not good at that!
If you can use SQL server for both apps, it's a whole lot easier (and safer).

How much control have you got over the "other app"? Because if you haven't got any, how will it react if it finds it can't write the data because your app is busy reading it?
Ekona_Pikin 16-Mar-15 13:17pm    
I would have Two [Buttons and a RichTextBox], one to connect to the Access_DB and another to perform some calculations based on what it pulled from the Database.

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