Kavvy <r@hfeajhjgg.gt> wrote:
After messing about I've made some headway towards getting a DataSet filled
with data from an SQL database, unfortunately I've been advised that this
isn't the way forward due to the overhead involved of filling the DataSet
with every page access.
So what method is prefereable to use?
Am I supposed to create a DataAdapter that only fetches a certain query,
dependant on what the users type in fields? Or am I supposed to use a
DataSet in the same way?
I normally use a DataSet *with* a DataAdapter - or bypass a DataSet
entirely and just use DataTables directly. (I don't think DataSets
really give that much benefit as a collection, but that could just be
due to the apps I happen to have written not needing the extra
functionality.)
You'd normally have a DataAdapter with a command already populated, and
then set the parameter values of that command from what the user types
in.
The book I bought is pretty useless in the respect that it focuses on the
DataSet as the all-encompasing solution to all your needs. Which I debate
TBH.
All I want to do is execute SQL queries and put the results in to text
boxes, then update the SQL tables with an update query afterwards....
To be honest, using a DataSet (or at least a DataTable) is still
probably the way to go. The only other viable alternative would be to
use a DataReader, which doesn't really buy you much - you might get
*slightly* more efficiency, but your code would be longer and more
fragile.
Using DataTable/DataAdapter will make the update much easier, too.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too