vb.net - how to edit/delete records in a datagridview? -


i'm using code deleting of records in datagridview using vb.net , sql -12

 private sub delete_click(byval sender object, byval e eventargs) handles delete.click     if messagebox.show("delete item?", "delete!", messageboxbuttons.yesno, messageboxicon.warning) = windows.forms.dialogresult.yes         me.datagridview.rows.removeat(me.datagridview.currentrow.)     else         datagridview.update()     end if end sub 

when i'm using this, record gets deleted temporarily not permanently database. how should delete records permanently? same case when i'm editing field. it's temporary.

then set deletecommand sqldataadapter. code depends on table's keyid name , type, among other things.

dim connection sqlconnection  dim adapter sqldataadapter = new sqldataadapter() ... (here wrote dataadapter fill code) ... dim cmddelete new sqlcommand("delete customers keyid = @keyid", connection) cmddelete.parameters.add("@keyid", sqldbtype.nchar, 8, "keyid") adapter.deletecommand = command 

i think dataadapter wizard should have done though.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -