G
Guest
ADO.NET seems to provide a million objects for accessing data and I'm a little confused.
First, let me describe how the data is accessed on my site:
- ALL data is accessed through calls to stored procedures which may or may not change data in the database but which ALWAYS return data (sometimes multiple rows, sometimes only 1).
- I NEVER return more than one table of data from any database call.
- I NEVER edit data in the database by changing the result set returned from a previous call. In other words, if changes are made to the database, it's ALWAYS through calls to new stored procedures and not by the "disconnected data" business.
So, in the end, I only use data which comes back from the database in one of three ways:
1. I programmatically access the data returned and make decisions based on it.
2. I use DataGrids and other nice tools for display-only data-binding (no pagination either).
3. I store tables of data returned from the database in the Application Object for repeated binding to things like pull-down controls, etc.
I'm looking for the most efficient and resource-sensitive objects to use for each of these functions above (1, 2, and 3) and I'm confused.
Do I use the DataTable object for all of them? It seems like a nice, simple structure that is disconnected from the database after data is returned. I can also store it and use it over and over again to bind to pull-down controls, etc. I read that the DataReader was the most efficient, but you don't seem to be able to re-use the data in it once the DataReader is "Closed."
Your guidance is appreciated.
Alex
First, let me describe how the data is accessed on my site:
- ALL data is accessed through calls to stored procedures which may or may not change data in the database but which ALWAYS return data (sometimes multiple rows, sometimes only 1).
- I NEVER return more than one table of data from any database call.
- I NEVER edit data in the database by changing the result set returned from a previous call. In other words, if changes are made to the database, it's ALWAYS through calls to new stored procedures and not by the "disconnected data" business.
So, in the end, I only use data which comes back from the database in one of three ways:
1. I programmatically access the data returned and make decisions based on it.
2. I use DataGrids and other nice tools for display-only data-binding (no pagination either).
3. I store tables of data returned from the database in the Application Object for repeated binding to things like pull-down controls, etc.
I'm looking for the most efficient and resource-sensitive objects to use for each of these functions above (1, 2, and 3) and I'm confused.
Do I use the DataTable object for all of them? It seems like a nice, simple structure that is disconnected from the database after data is returned. I can also store it and use it over and over again to bind to pull-down controls, etc. I read that the DataReader was the most efficient, but you don't seem to be able to re-use the data in it once the DataReader is "Closed."
Your guidance is appreciated.
Alex