468,294 Members | 1,942 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,294 developers. It's quick & easy.

fetching boolean value from sql query result

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
3 5799
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
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
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.

Similar topics

6 posts views Thread by google | last post: by
1 post views Thread by Rhio Barnhart | last post: by
14 posts views Thread by greg | last post: by
22 posts views Thread by Sandman | last post: by
1 post views Thread by Frank Moyles | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.