Saving to data base

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I save data without connecting to data base every time a client's
request
arrives?
If I work on a temporary memory I cannot work with sql queries, but connecting
to data base takes time.
 
How can I save data without connecting to data base every time a client's
request
arrives?
If I work on a temporary memory I cannot work with sql queries, but connecting
to data base takes time.

If all you need to do is save the data and not query the database on
each request, just buffer the data in temporary memory and flush it
out to the database at intervals. I use a separate thread to access
the database and flush the accumulated data so as not to interfere
with ongoing data collection. That way, it doesn't really matter if
the database is occasionally a bit slow.
 
How can I save data without connecting to data base every time a
If all you need to do is save the data and not query the database on
each request, just buffer the data in temporary memory and flush it
out to the database at intervals. I use a separate thread to access
the database and flush the accumulated data so as not to interfere
with ongoing data collection. That way, it doesn't really matter if
the database is occasionally a bit slow.

Just keep in mind, that in case of system crashes your data, which are
not written to the database, are not available anymore. So I think it's
depending on your use case, for most situations this is fine, but if you
go into some user login, accounting or similar, then it is crucial, that
the data the user submits really get written to the database, or if an
error occurs there, that the user is notified immediately of the error.

Markus
 
aaa said:
How can I save data without connecting to data base every time a client's
request
arrives?
If I work on a temporary memory I cannot work with sql queries, but
connecting
to data base takes time.

If you use the same connection string every time, then connection pooling
should take care of most of the delays caused by logging in. I assume you
are using SQL Server or SQL Server Express (the free version). Other
databases, like MySQL, may or may not offer this feature.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
 
Back
Top