c# - how to delete image which is stored as varbinary format in database -


i have picturebox image , delete button. image stored in varbinary(max) format in database. how delete when delete button pressed?

i'm using code save image database:

byte[] data;  using (system.io.memorystream stream = new system.io.memorystream()) {     conn.open();      image img = picturebox1.image;     img.save(stream, system.drawing.imaging.imageformat.jpeg);     data = stream.toarray();      cmd.commandtext = "insert images values(@images)";      cmd.parameters.addwithvalue("@images", data);      int res = cmd.executenonquery();     messagebox.show("success"); } 

i don't see why following wouldn't work.

cmd.commandtext = "delete images id = x";

sending plain sql getting outdated , can down right dangerous when implemented ui improperly, should consider using linq

http://en.wikipedia.org/wiki/language_integrated_query


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -