Converting datareader value

T

Toska

Which method is the most effective.


-
bool b = (bool)dr["column"];
-
bool b = Convert.ToBoolean(dr["column"]);
-
bool b = dr.GetBoolean(0);
-
Other.
 
S

sloan

The pdf doesn't exist anymore, but I had this commented in my code:

//''FROM http://www.stevearnott.com/DAAG.pdf
// 'When accessing data by using the reader, use the typed
accessor methods (such
// 'as GetInt32 and GetString) if you know the column's
underlying data type
// 'because they reduce the amount of type conversion required
when you read
// 'column data.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top