473,395 Members | 1,474 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,395 software developers and data experts.

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 6034
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: google | last post by:
I would like to find a way to execute a query against an MS SQL server and return a small number of rows each page load. However, I cannot read all the results in during the first page load due to...
1
by: Rhio Barnhart | last post by:
I am a MySQL/PHP beginner and have gotten further than I expected. I am developing a web based library catalog. After getting everything configured, I have been working on various query formats. ...
14
by: greg | last post by:
Discussion is invited on the following proto-PEP. ------------------------------------------------------------- PEP ??? - Overloadable Boolean Operators...
7
by: rguarnieri | last post by:
Hi! I'm trying to create a query with a boolean expression like this: select (4 and 1) as Value from Table1 this query return always -1, but when I make the same calculation in visual...
22
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other...
2
by: pushpa4385 | last post by:
hi, i have fetching record from mysql database in this formate <?php $connsqlhostname = "localhost"; $connbase = "rajgorsamaj"; $connlogin = "pushpa"; $connpassword = "123456";
1
by: Frank Moyles | last post by:
I have two simple function in PHP that I want to convert to C# - function Doit($enc_user_name, $enc_password) { $result = $mysqli->query("call sp_userAuth('$enc_user_name','$enc_password')"); ...
4
by: Yitzak | last post by:
Have a query that is arregated into crosstab query, it is working correctly. select Yes as selected from tblname or select true as selected from tblname Produces -1 ( vba value of True) in...
1
by: padmaneha | last post by:
I executed the below query for getting the details of dishes which are tagged to the festival 'Durga Pooja' select fg.tagname, fg.foodid, f.dishes, f.dishtype from foodtag fg inner join food f ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...

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.