sql server - VB.Net Dataset checking null -
using vb.net , sql server
so dataset this:
dim ds3 new focusdatasettableadapters.gajitableadapter
and want item in dataset array. dataset empty now.. try..
dim smp new list(of string)() try = 0 ds3.getdata.count - 1 if (ds3.getdata.rows(0).item(3) nothing) smp.add("0") end if next catch ex exception = - 1 end try
so want is.. if database null/empty add "0" array. everytime run code gives me error state there row @ current position (0)...
your code should (maybe necessary more modification - snippet cannot tested):
try dim tbl datatable=ds3.getdata() = 0 tbl.rows.count - 1 if (tbl.rows(i).item(3) dbnull.value) smp.add("0") end if next catch ex exception = - 1 'rather strange , causes endless loop end try
you should aware getdata
method returns datatable , want iterate it. reconsider errorhandling!
Comments
Post a Comment