473,508 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

preferred syntax for datareader?

Hi - what's best:

ResourceName = CType(dtr("ResourcePoolName"), String)
or
ResourceName = dtr("ResourcePoolName").ToString
or
ResourceName = dtr.GetString(dtr.GetOrdinal("ResourcePoolName"))
or ....?
I guess my main criteria is runtime performance. I don't want to use
dtr.getString(0) in case the field orders change.

Thanks,
Paul.
Nov 21 '05 #1
2 1268
Hi Paul,

I would use 3rd option with a slight modification - store the ordinal value
before going into loop and then use the stored value.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"Paul W" <qq*@qqq.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi - what's best:

ResourceName = CType(dtr("ResourcePoolName"), String)
or
ResourceName = dtr("ResourcePoolName").ToString
or
ResourceName = dtr.GetString(dtr.GetOrdinal("ResourcePoolName"))
or ....?
I guess my main criteria is runtime performance. I don't want to use
dtr.getString(0) in case the field orders change.

Thanks,
Paul.

Nov 21 '05 #2
Hi Paul,

I would use 3rd option with a slight modification - store the ordinal value
before going into loop and then use the stored value.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
SLODUG - Slovene Developer Users Group
www.rthand.com

"Paul W" <qq*@qqq.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi - what's best:

ResourceName = CType(dtr("ResourcePoolName"), String)
or
ResourceName = dtr("ResourcePoolName").ToString
or
ResourceName = dtr.GetString(dtr.GetOrdinal("ResourcePoolName"))
or ....?
I guess my main criteria is runtime performance. I don't want to use
dtr.getString(0) in case the field orders change.

Thanks,
Paul.

Nov 21 '05 #3

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

Similar topics

6
363
by: Yasutaka Ito | last post by:
Hi, My friend had a little confusion about the working of DataReader after reading an article from MSDN. Following is a message from him... <!-- Message starts --> I was going thru DataReader...
6
750
by: Ravi | last post by:
Hi, I am not able to understand why a datareader needs a connection to the DB all the time. Here is what I tried. Sqlcommand cmd = ("select * from table1",con) // where con is the connection...
2
1280
by: sean | last post by:
Hi, I am filling a datagrid and I was wondering how I can test for "end of file" and then make decisions based on that. I am still making the transition from asp to asp.net. Could someone...
20
5509
by: Mark | last post by:
Hi all, quick question , a DataView is memory resident "view" of data in a data table therefore once populated you can close the connection to the database. Garbage collection can then be used to...
2
1565
by: Andrei Pociu | last post by:
In a typical ASP .NET Web Application (website), I'm currently using a class where I declare some public static objects. For example there's the place where I initialize the SqlConnection. Also...
2
1399
by: Darrel | last post by:
I'm trying to perform a SQL query and then bind the results to two different dropdownlists. Unfortunately, I can only get it to bind to one...whichever one of the two I try to bind first: Dim...
1
3084
by: Brent | last post by:
I'm having a hard time wrapping my head around how to build a multi-dimensional array of n length out of a DataReader loop. Take this pseudo-code: ======================================= public...
7
3377
by: Varangian | last post by:
Hi all, the question I want to ask if the conversion of a DataReader to a Table looping through the DataReader is better than using the Fill Method of the DataAdapter... I'm asking because...
7
2894
by: Diffident | last post by:
Hello All, I would like to use DataReader based accessing in my Data Access Layer (DAL). What is considered to be a best practice while returning from a DAL method that executes a query and...
3
3376
by: Johnny Jörgensen | last post by:
I've got an error that I simply cannot locate: I've got a form in which I use a datareader object to read information from a db. After the read, I close the reader and I dispose of both the...
0
7231
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
7401
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7063
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
7504
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
5640
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,...
1
5059
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4720
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
3211
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
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.