vb.net - Refresh DataGridView after executing SQL Command? -
here code:
cn.open() cmd.commandtext = "insert student values('" ...... cmd.executenonquery() cn.close()
after closing connection want datagridview refresh it's data's also.
new in vb.net tried datagridview.refresh()
it's not working think it's repainting not updating it's data's.
thanks.
if update underlying business object, ui should update automatically. guess forgot data binding, example datagridview.datasource = yourdatatable
.
edit: easiest way right replace this:
cmd.executenonquery()
with this:
dim dt new datatable dt.load(cmd.executereader())
and then:
datagridview.datasource = dt
if need database updates, may want use dataadapter , update method. overload linked datatable, i.e. don't need dataset, unless have already.
Comments
Post a Comment