There are a few problems here. With your existing code, you need to re-think it as the
documentation[
^] is very clear:
Remarks:
You must keep the stream open for the lifetime of the Image.
Since your stream is created and no reference to it is preserved once the method ends, it is liable for Disposal at any time the GC decides.
It's also considered a bad idea to use
SELECT * FROM tblQrBar
as it pulls all columns - you should specify only the data you are actually interested in to save bandwidth:
SELECT QrImage, BarImage FROM tblQrBar
You also don't limit the number of rows you pull in, so if
AddItem
adds data to a control of some form then you are going to get a very slow and resource hungry app pretty quickly as codes are added to your system: Page them, sort them, search them, filter them - don't just dump them on the user and let him sort it out!
The problem you have noticed is likely to be outside that code: check your code to insert images to your DB - best guess is you INSERT the same image twice when you load your DB.