vb.net - Unable to delete data from a MS Access database -
i unable delete data database. code:
dim deletedata oledbcommand conn.open() sql1 = ("delete etat_projet nom_du_client= &textbox1.text") deletedata = new oledbcommand(sql1, conn) deletedata.executenonquery() me.close()
this capture of database , record still exists:
you need pass textbox1.text
parameter command so:
sql1 = "delete etat_projet nom_du_client = ?" deletedata = new oledbcommand(sql1, conn) deletedata.parameters.add("@nom", oledbtype.[type]).value = textbox1.text deletedata.executenonquery()
note have used
oledbtype.[type]
. want replace data type have specified columns.
i consider implementing using:
sometimes code requires unmanaged resource, such file handle, com wrapper, or sql connection. using block guarantees disposal of 1 or more such resources when code finished them. makes them available other code use.
using con new oledbconnection(connectionstring), cmd new oledbcommand("delete etat_projet nom_du_client = ?", con) cmd.parameters.add("@nom", oledbtype.[type]).value = textbox1.text cmd.executenonquery() end using
Comments
Post a Comment