vb.net - Error in saving record into MS Access database -
i have got couple of errors in code in vb , cant figure out how solve it.
first error in following part says value cannot null parameter name: data table
da.fill(dt, "order") con.close()
the second error in part:
dsnewrow = ds.tables(0).newrow()
and here whole code:
private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load dbprovider = "provider=microsoft.ace.oledb.12.0;" dbsource = "data source=c:\users\pao\desktop\projecto1.accdb" con.connectionstring = dbprovider & dbsource con.open() sql = "select *from order" da = new oledb.oledbdataadapter(sql, con) da.fill(dt, "order") con.close() end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click if name_.textlength > 0 , address_.textlength > 0 , key.textlength > 0 dim pizzaarr() = pizza.toarray() dim spagarr() = spaghetti.toarray() dim grindersarr() = grinders.toarray() dim dsnewrow datarow each element string in grindersarr msgbox(element) next dsnewrow = ds.tables(0).newrow() dsnewrow.item(0) = key.text dsnewrow.item(1) = name_.text dsnewrow.item(2) = address_.text ds.tables("order").rows.add(dsnewrow) da.update(ds, "order") msgbox("order added", msgboxstyle.information, "record") maxrows = ds.tables("order").rows.count '' else msgbox("complete form!", msgboxstyle.exclamation, "incomplete!") exit sub end if '' dim cb new oledb.oledbcommandbuilder(da) '' dim dsnewrow datarow '' dsnewrow = ds.tables("form").newrow() '' dsnewrow.item(0) = key.text '' dsnewrow.item(1) = name_.text '' dsnewrow.item(2) = address_.text '' ds.tables("form").rows.add(dsnewrow) msgbox("record added", msgboxstyle.information, "record") maxrows = ds.tables("form").rows.count end sub
Comments
Post a Comment