Quote:I have removed the image from the but_Driver_Licence.BackgroundImage button before entering this routine.
That doesn't mean that the file is freed. If you loaded the image from the file using Image.FromFile, then the documentation is pretty clear: Image.FromFile Method (String, Boolean) (System.Drawing)
Quote:The file remains locked until the Image is disposed.
Which means as long as your code has not explicitly called Dispose on the Image class instance itself, the file cannot be written, moved or deleted.
When you remove it from the Button, Dispose it - or better when you load teh file into an image, copy it to a new bitmap and Dispose the original so that teh period it is locked is as short as possible.
And don't do database access like that: Never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.