Answered by:
sql datasource versus datareader/dataset

Question
-
User54991879 posted
I need to bind the output of a stored procedure to a gridview. There are many ways to do it.
1>I could the results in a dataset and bind it to the gridview or
2>I could use a sqldatasource and bind its output to the gridview.
I personally perfer sqldatasource becaue its fewer lines of code, easy to maintain and simple.
But can anyone tell me why one of them should be used over the other?
Monday, December 24, 2007 3:02 PM
Answers
-
User-1552089523 posted
Both dataset and sqldatasource have their own cons and pros.
Personally i prefer to use dataset, over sqldatasrouce in my code.
One of the advantage of using dataset is that, you can add / remove columns on the fly to the dataset object,
second you can store not only mutliple tables in single dataset object but also information regarding their relationship,
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 24, 2007 3:47 PM -
User-821857111 posted
If you prefer the SqlDataSource, then that's the one you should use. There's absolutely nothing wrong with using it.
The main reason why some people don't use it is because they feel the need to keep their data access code in its own "layer". That means not in the code-behind. For a lot of sites though, this is unecessary.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 24, 2007 3:50 PM
All replies
-
User-1552089523 posted
Both dataset and sqldatasource have their own cons and pros.
Personally i prefer to use dataset, over sqldatasrouce in my code.
One of the advantage of using dataset is that, you can add / remove columns on the fly to the dataset object,
second you can store not only mutliple tables in single dataset object but also information regarding their relationship,
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 24, 2007 3:47 PM -
User-821857111 posted
If you prefer the SqlDataSource, then that's the one you should use. There's absolutely nothing wrong with using it.
The main reason why some people don't use it is because they feel the need to keep their data access code in its own "layer". That means not in the code-behind. For a lot of sites though, this is unecessary.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, December 24, 2007 3:50 PM