By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,424 Members | 1,382 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,424 IT Pros & Developers. It's quick & easy.

fetching boolean value from sql query result

P: n/a
trying to get a boolean value from DataReader (that is, result from a SQL
query);

boolean MyBool = MyDataReader.GetBoolean(3);

well it works using that number 3 but of course I would like to do something
like
... = MyDataReader.GetBoolean["IsLocked"];

since I don't always know the field number of the IsLocked field. Why is
this so complicated and what is the best solution??
Nov 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try

.... = MyDataReader.GetBoolean(MyDataReader.GetOrdinal("I sLocked"));

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.
"Daves" <db****@simnet.is> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
trying to get a boolean value from DataReader (that is, result from a SQL
query);

boolean MyBool = MyDataReader.GetBoolean(3);

well it works using that number 3 but of course I would like to do
something like
... = MyDataReader.GetBoolean["IsLocked"];

since I don't always know the field number of the IsLocked field. Why is
this so complicated and what is the best solution??

Nov 16 '05 #2

P: n/a
thx this works 100%
But why does ADO make it so complex to use DataReader["fieldname"] for
fetching the field values? It is as if it wants me by default to get them by
DataReader(field number) but this field number could so easily change if the
sql query is changed and ... an error would be produced. Am I missing
something?
"Kai Brinkmann [MSFT]" <ka******@online.microsoft.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Try

... = MyDataReader.GetBoolean(MyDataReader.GetOrdinal("I sLocked"));

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Daves" <db****@simnet.is> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
trying to get a boolean value from DataReader (that is, result from a SQL
query);

boolean MyBool = MyDataReader.GetBoolean(3);

well it works using that number 3 but of course I would like to do
something like
... = MyDataReader.GetBoolean["IsLocked"];

since I don't always know the field number of the IsLocked field. Why is
this so complicated and what is the best solution??


Nov 16 '05 #3

P: n/a
ok think I got it. What I needed to do was casting and use the casting
correctly, seems I used int where should have been int32 for example...

"Daves" <db****@simnet.is> wrote in message
news:u8**************@TK2MSFTNGP09.phx.gbl...
thx this works 100%
But why does ADO make it so complex to use DataReader["fieldname"] for
fetching the field values? It is as if it wants me by default to get them
by DataReader(field number) but this field number could so easily change
if the sql query is changed and ... an error would be produced. Am I
missing something?
"Kai Brinkmann [MSFT]" <ka******@online.microsoft.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...
Try

... = MyDataReader.GetBoolean(MyDataReader.GetOrdinal("I sLocked"));

--
Kai Brinkmann [MSFT]

Please do not send e-mail directly to this alias. This alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no
rights.
"Daves" <db****@simnet.is> wrote in message
news:OU**************@TK2MSFTNGP09.phx.gbl...
trying to get a boolean value from DataReader (that is, result from a
SQL query);

boolean MyBool = MyDataReader.GetBoolean(3);

well it works using that number 3 but of course I would like to do
something like
... = MyDataReader.GetBoolean["IsLocked"];

since I don't always know the field number of the IsLocked field. Why is
this so complicated and what is the best solution??



Nov 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.