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
Post a Comment