2014年7月13日 星期日

[RESOLVED] DataReader or Dataset ?


hi guyz...


Iam unable to understand,i have to use datareader or dataset?



Iam currently working on social n/w site where in i have to get n number of post's....



so shud i use data reader or dataset?


as i have learned datareader is fast?but question is its connection oriented?


so shud i use data reader or dataset???



experts view required....



Please ..



Thanks.



Hi, 


Datareader is ready only, forword only very fast to retrive data from database. 


while DataSet actually uses a DataReader to populate itself. A DataReader is a lean, mean access method that returns results as soon as they’re available, rather than waiting for the whole of the query to be populated into a DataSet. This can boost your
application performance quite dramatically. dataset require data adapter.... DataSets are read/write and you can also move forwards and backwards through them.


to me the trade off is performance vs. updatablity.


I would suggest to go with datareader if you do not want to update, persist data,store multipal tables,relations between the tables


for more detail information http://social.msdn.microsoft.com/Forums/en-US/8867da46-2f32-4f0c-a76d-c7c81c52729b/datareader-vs-dataset-for-dropdownlist






Actually the difference is connected and dis-connected model of data access, data-reader is connected model however data-set is dis-connected model, mean you can get all the data in data-set and immediately close the db connection. perform your changes in
data-set (offline) and when changes are done, update the db with these changes. 



if iam using data reader and multiple users are requesting the data,then is there any problem?




Hi,


While the data reader is not thread safe (it says as much in the documentation), I think that this stems from the connection, and not the reader itself. You should be marshaling the call across threads, or establishing the connection on the thread that will
access it.


Source from
http://www.pcreview.co.uk/forums/sqldatareader-thread-safe-t1356433.html


And refer the thread


http://stackoverflow.com/questions/1083193/whats-better-dataset-or-datareader


Hope it can help you





zuber2103



if iam using data reader and multiple users are requesting the data,then is there any problem?





You should be fine. Don't share the reader or connection between users and you should be ok. The key thing though with datareaders is to open the connection right before you execute the reader, and close it immediately after you are done with it. Connections
are one of the most precious resources you have on a server and closing and disposing of a connection right as soon as the datareader is done will help to release the connection and return it to the pool all the faster. This will help avoid issues where you
can run out of connections in the pool if they aren't released fast enough (or they aren't released at all).


沒有留言:

張貼留言