473,503 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

querying columns from tables

Hi all
If I have to read just one or two columns from my SQL
server table, is data reader the only option? or is there
a more efficient way?
Thanks a lot in advance for your replies.
Nov 15 '05 #1
2 1039
It depends on what you want to do. A DataReader is a very fast way to read
data, but the tradeoff is functionality. DataReaders only work when there's
an open DB connection and they are forward only /read only. If efficiency
is the only concern, then DataReaders are probably what you need. But using
a DataAdapter/Dataset and disconnected objects are probably something you'll
want to use in the majority of your apps.

It's a right tool for the right job. While a Concord might be a very fast
transport mechanism, it's a bit much as a vehicle to get to work in. On the
other hand, an 18 Wheeler can do many things for you functionally, but there
are times you don't need all of that functionality so it's overkill. These
analogies are a bit extreme, but the point is that things are often more
like Tradeoffs than either/ors. And there's no universal answer for things
like this..what make be a great solution in one app is terrible in another.
What was a great solution when you had 20000 records might be terrible when
you have 50000000.

If you are new to ADO.NET, you'll probably want to pick up David Sceppa's
ADO.NET Core Reference, Bill Vaughn's Best Practices http://www.betav.com/
And if at all possible both of them. You may also want to check out the
DAAB which is Microsoft's Best Practices for Data Access.
http://msdn.microsoft.com/library/de...us/dnbda/html/
daab-rm.asp
"C# newcomer" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi all
If I have to read just one or two columns from my SQL
server table, is data reader the only option? or is there
a more efficient way?
Thanks a lot in advance for your replies.

Nov 15 '05 #2
You can use the datareader regardless of how many columns you want to read.
Just make sure the stored procedure or sql statement only selects the
columns you need.
Arild

"C# newcomer" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Hi all
If I have to read just one or two columns from my SQL
server table, is data reader the only option? or is there
a more efficient way?
Thanks a lot in advance for your replies.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2336
by: J Belly | last post by:
Hi, all: This is probably a simple problem, but, as an SQL newbie, I'm having a little trouble understanding multi-joins and subqueries. I have the following tables and columns: ...
5
2348
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
4
2263
by: onecorp | last post by:
I have a SQL table comprised of 31 columns. The first column is simply an id column, the next 30 columns are labelled ,.... The numerical columns have a tinyint type and the data stored is either...
1
1596
by: SilRay | last post by:
I will admit up front that this is to help with an assignment for a class, however, I'm looking for information outside the scope of the assignment because I want to do something cooler. The...
4
1364
by: mcmahon | last post by:
Hi, I have a MS Access DB with a query that I need to display in vb but am not too sure on how to go about it. The query has some criteria - i.e you have to input a date to run the query. I think...
0
7204
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7091
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6998
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7464
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5586
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4680
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1516
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.