473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 1261
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
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
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

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.