vb.net - NullReferenceException error in VB Application? -
i'm building voting system calls, , have tried build in vb. far have:
dim con new oledb.oledbconnection dim dbprovider string dim dbsource string dbprovider = "provider=microsoft.jet.oledb.4.0;" dbsource = "data source = c:\phonepoll.mdb" con.connectionstring = dbprovider & dbsource con.connectionstring = "provider=microsoft.jet.oledb.4.0;data source = c:\phonepoll.mdb" con.open() 'sql = "select * voting" 'da = new oledb.oledbdataadapter(sql, con) 'da.fill(ds, "voting") if inc <> -1 dim cb new oledb.oledbcommandbuilder(da) dim dsnewrow datarow dsnewrow = ds.tables("voting").newrow() dsnewrow.item("voted") = radiobutton1.checked.tostring dsnewrow.item("voted") = radiobutton2.checked.tostring dsnewrow.item("voted") = radiobutton3.checked.tostring dsnewrow.item("voted") = radiobutton4.checked.tostring ds.tables("voting").rows.add(dsnewrow) da.update(ds, "voting") msgbox("new record added database") end if msgbox("phone call has been logged") con.close() this code contained within "record call" button. on form, there 4 radio buttons, different text values should entered in "voting" table.
my problem when select radio button , click on "record button" displays error:
nullreferenceexception: object reference not set instance of object.
this error displayed on line
dsnewrow = ds.tables("voting").newrow() i'm not sure i've done wrong.
cheers help!
i assuming in real code don't have sql , fill() method dataset commented out , typo in code above - right? if wrong , block of code commented out, dataset null , that's issue...
Comments
Post a Comment