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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -