c# - Check if datareader is empty -
this question has answer here:
i'm constant receive error:
additional information: data null. method or property cannot called on null values.
when try receive information. how can check if datareader empty.
for example code:
while (rd.read()) { if (rd.hasrows) { foundinformation[0] = rd.getstring(0); foundinformation[1] = rd.getstring(1); } else { foundinformation[0] = "nvt"; foundinformation[1] = "nvt"; } }
how can check if rd.getstring(0) empty?
thankyou.
you need call isdbnull before call getstring.
if (!rd.isdbnull(0)) { //... }
Comments
Post a Comment