Need to grab an image off the disk, preview in a picturebox, then save
in SQL database for later viewing, etc.
Got the "grab/preview" part working fine, and *something* is being
stored in the SQL database, but when I go to retrieve the image and
place it in the picture box, the picture is blank. SQL datatype is
image, and the tableadapter has an update query that accepts the image
field and primary key. Image field is sent as a byte array. Length
of the image in SQL is 2 bytes more than the file on disk.
So, in trying to debug....
I've found that if I do a picturebox.imag e.save("c:\save d.tif",TIFF)
it saves it just fine, and the resultant image file on disk is
readible. But, if I do:
picturebox.imag e.save(memorySt ream,TIFF)
memoryStream.re ad(byteArray,0, memoryStream.le ngth)
system.io.file. writeAllBytes(" c:\bytes.tif",b yteArray)
the resultant file on disk is not a readible TIFF image.
....which makes me wonder how I'm supposed to convert BLOB data for
storage and retrieval in SQL. I've read through many articles which
suggest that I should:
dim byteArr(imageCo ntent.length)
imageContent.re ad(byteArr,0,im ageContent.leng th)
tableAdapter.up dateQuery(byteA rr,primaryKey)
where imageContent is system.io.fileS tream and is initialized to
system.io.file. openRead(filePa thOnDisk).
And it *appears* to work - well, it stores *something* in the SQL
database, but whatever it's storing is illegible. And when I try the
same series of steps but save to disk, it's also not recognizable as a
TIFF file.
Which takes me back to the question - how do I get BLOB data (TIFF or
other image/picture data) into SQL so that I can extract it back from
SQL and view it in a picturebox (VB.Net 2.x)?
in SQL database for later viewing, etc.
Got the "grab/preview" part working fine, and *something* is being
stored in the SQL database, but when I go to retrieve the image and
place it in the picture box, the picture is blank. SQL datatype is
image, and the tableadapter has an update query that accepts the image
field and primary key. Image field is sent as a byte array. Length
of the image in SQL is 2 bytes more than the file on disk.
So, in trying to debug....
I've found that if I do a picturebox.imag e.save("c:\save d.tif",TIFF)
it saves it just fine, and the resultant image file on disk is
readible. But, if I do:
picturebox.imag e.save(memorySt ream,TIFF)
memoryStream.re ad(byteArray,0, memoryStream.le ngth)
system.io.file. writeAllBytes(" c:\bytes.tif",b yteArray)
the resultant file on disk is not a readible TIFF image.
....which makes me wonder how I'm supposed to convert BLOB data for
storage and retrieval in SQL. I've read through many articles which
suggest that I should:
dim byteArr(imageCo ntent.length)
imageContent.re ad(byteArr,0,im ageContent.leng th)
tableAdapter.up dateQuery(byteA rr,primaryKey)
where imageContent is system.io.fileS tream and is initialized to
system.io.file. openRead(filePa thOnDisk).
And it *appears* to work - well, it stores *something* in the SQL
database, but whatever it's storing is illegible. And when I try the
same series of steps but save to disk, it's also not recognizable as a
TIFF file.
Which takes me back to the question - how do I get BLOB data (TIFF or
other image/picture data) into SQL so that I can extract it back from
SQL and view it in a picturebox (VB.Net 2.x)?
Comment