vb.net 2010 - NullReferenceException is not managed. "Tables" returns nothing. why? -
here code. it's first time @ vb.net.
private sub accountnum_keypress(byval sender object, byval e system.windows.forms.keypresseventargs) handles accountnum.keypress dim index long = 0 if asc(e.keychar) = 13 while index <= 111000 if accountnum.text = ds.tables("dbo.accountmaster").rows(index).item("accountnumber").tostring nameconsumer.text = ds.tables("dbo.accountmaster").rows(index).item("consumername") address.text = ds.tables("dbo.accountmaster").rows(index).item("consumeraddress") end if loop end if end sub
the null reference error means you're attempting take action on object value has not been set. it's not uncommon people lose sight of source of these errors when using language handy dot notation.
take @ example line 5 in snippet: ds.tables("dbo.accountmaster").rows(index).item("accountnumber").tostring
this isn't uncommon you're chaining 4 references here , assuming they're valid. @ line error occurred on , check each component in statement value. in line above want check: - ds - ds.tables("dbo.accountmaster") - ds.tables("dbo.accountmaster").rows(index) - etc.
if of null subsequent action attempt take on result, e.g. tostring result in null reference exception.
Comments
Post a Comment