Goodday
I can’t seem to use my dataset in a Null comparison
I’m trying to make an statement (attempts go below) where it will only continue my code when my dataset is empty.
Code 1:
if ((string)dts.Tables[0].Rows[0]["RECID"] != null)
^ just skips my if, I know that it’s empty (checked my watch), still continues even when it is null.
Code 2:
long Recid = 0;
Boolean checkrecid = long.TryParse((string)dts.Tables[0].Rows[0]["RECID"], out Recid);
if (checkrecid == false)
^ Crashes at my Tryparse. I know you can use Trycatching, but I don’t want to use it, cause it will make my program run slower, and it needs to read a good 10000 lines a day …
Error:
A first chance exception of type 'System.IndexOutOfRangeException' occurred in System.Data.dll
Meaning that it can’t find anything, but I know that already.
EDIT: I do not want an error. Any previous methods, who all work in other cases, return an indexoutofrange error. I’ll add this ..
The dataset is filled with data from an SQL server based on phonenumbers and other data.
If he can’t find the phonenumber, which comes from a text file, he will return nothing, no row, no column, nothing.
Thanks in advance,
DZ
Found it!