Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

verifying if a table row has data

Status
Not open for further replies.

ukemike

Programmer
Aug 14, 2003
8
US
Hi guys a got a question for you.
I am reading in from an oracle table into a form and in order to see when there is no more records i do:

if (a["CUS_ID"]=="")
{
lstBoxSearchResults.Items.Add("No results found");
} else {


whatver........
now CUS_ID is my primary key in my table so every record has it. a is my DataReader. i do this in a loop and it will read and write to the form and read and write to the form but when the last record is read into 'a', it goes to that if statement and an exception happens. i tried doing this also:
if ((a["CUS_ID"]==null) || (a["CUS_ID"]==""))
and it still throws that "no data in row/column" exception. how can i catch this in an if statement. i mean i can put this in an try catch block but that takes up cpu time.

any ideas??
thank you
mike
 
Hi,
You cannot use an 'equality' test for NULL -
(BTW, an empty string "" is considered NULL by Oracle )
Try
if ((a&quot;CUS_ID&quot; < &quot;0&quot;) || (a&quot;CUS_ID&quot;==&quot; &quot;))
instead.

( The < &quot;0&quot; part checks for any contents in a sting since the string's ascii value will be greater then 0 )


[profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top