I am building a web application that connects to sql server.
The process is like so : the user log in the site and from that moment there a few connections to the data base, but another thing that arrives from the data base is a representation of the client`s company as an object. the client may change some of the data during the time of the session. and when the session ends(the client closes the browser). the object sent to the data base.
So the question is from the moment that i brought the table to the code behind how should i keep it. in a datatable or ini file.
Keep in mind that this is browser and i want to keep it as fast as possible.
Thank to you all.
I am building a web application that connects to sql server. The process is
Share
You should keep the data in the database, and read it from there at every page request. At least, there’s where you should start, and only consider caching data in memory if you actualy have any performance problems.
You should not keep a database connection open for the user, you should open a new connection for each request, and close it as soon as possible. The connections are pooled by the system and reused, so it doesn’t have to establish a new connection to the database each time you open one, but you should let the system take care of all that.
Data that is changed should be written to the database right away. Holding data in memory and writing it when the session ends has problems with stability and timing. The server doesn’t know when the user closes the browser, so the server consideres the session to end a time after the last request from thw user, usually 15 minutes. That means that the data would not be written when the user closes the browser, but up to 15 minutes later. If the user logs in again, the changes would show up after a while. If there is some problems with the server while it holds the data, the data would be lost, and the change would not be saved at all.