views:

193

answers:

3

Hi, I have an asp page based on a very simple database. It references a single table of probably 30 records and maybe 12 data fields and everything works great as I am only uploading a new database every week or so.

I have a special circumstance where I would like upload new data to the database and display automatically on the page every 20 to 30 seconds without the user having to refresh their screen. I would expect up to 1000 concurrent users accessing the data.

I have been manually uploading the database via ftp, which will obviously not work on this timeline and would also run the risk of error pages as the database is being replaced.

So, can anyone point me the right direction to setup this scenario?

Other details that might be helpful: The database is an Access database (but I could change to another format if needed) Running on Windows platform hosted by an ISP, not my own server

Thanks in advance for any help on this!

Lori

A: 

You need to know javascript in order to do this. Do you?

You would use the setTimeout() method in javascript to send a request to your server every 30 seconds for the updated content. This request would be an AJAX request.

Please see: http://www.asp.net/ajax/ for more information.

hobodave
No, I really don't know javascript, but you have given me a direction to go explore and learn. If I understand your answer, that will resolve how the user gets the data refreshed, but do you have any suggestions on continuously uploading the new data?Thanks for the help.
My automatic answer for automating anything on your server is to use a cron job. However Windows is lacking this. Perhaps you could use the windows scheduler? I dont use Windows, so I'm not the best person to advise you here.
hobodave
A: 

Instead of uploading a new database you should just update the records in the database on the server. That way you don't have any problem with the database being unavailable when the page wants to read from it.

There is no server push in the HTTP protocol, so you have to check for updates from the browser. You can use AJAX to call the server to keep the page from reloading.

Guffa
Thanks. It looks like you partially addressed my issue with uploading the data. However, I have to admit to being relatively inexperienced with this.The only way I have worked with data on my website is by full database upload. Can you give me a direction on how to upload single records to the server on a frequent basis like this? It will be coming out of a VB6 application if that helps.
Use an update or insert query to change the data in the database. You have to do this in a page on the server, so you can use the HttpRequest object to activate the page from your program and send the data to the page.
Guffa
A: 

If you are going to hand-roll your own Ajax solution you will need to understand the XmlHttpRequest object. This has a call back function that you can specify to update the HTML DOM with new data when it is returned and as @hobodave points out use the setTimeout() function to dellay the next request by however long is appropriate. You will need to make a web service to return the data either as pre-formatted HTML or in some data structure like XML or JSON.

When the user makes a new request they should only be sent the data that has changed. If no data changed then just send them a new time-stamp rather than all the data again. The request should always contain a time-stamp of the last successful update they received and then your request should return them only the new data that changed.

Depending how often you change the data you can cache all the processing of the data server side and just send them already formatted HTML to insert into the page.

Now each time you upload new rows, or alter rows (you need some SQL skills to avoid uploading the whole DB) you could generate the necessary output for the web page and just query that next time. You really don't want people constantly asking for data unless there is a likely hood that something has changed.

All that said, a very simple way to do this if you don't have to worry about stale data or excessive server side processing is to use a meta refresh tag to automatically make the whole page refresh but you may have performance issues if you have to process the data server side every time and this won't scale very well at all.

Dave Anderson