H
huntco
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.image.save("c:\saved.tif",TIFF)
it saves it just fine, and the resultant image file on disk is
readible. But, if I do:
picturebox.image.save(memoryStream,TIFF)
memoryStream.read(byteArray,0,memoryStream.length)
system.io.file.writeAllBytes("c:\bytes.tif",byteArray)
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(imageContent.length)
imageContent.read(byteArr,0,imageContent.length)
tableAdapter.updateQuery(byteArr,primaryKey)
where imageContent is system.io.fileStream and is initialized to
system.io.file.openRead(filePathOnDisk).
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.image.save("c:\saved.tif",TIFF)
it saves it just fine, and the resultant image file on disk is
readible. But, if I do:
picturebox.image.save(memoryStream,TIFF)
memoryStream.read(byteArray,0,memoryStream.length)
system.io.file.writeAllBytes("c:\bytes.tif",byteArray)
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(imageContent.length)
imageContent.read(byteArr,0,imageContent.length)
tableAdapter.updateQuery(byteArr,primaryKey)
where imageContent is system.io.fileStream and is initialized to
system.io.file.openRead(filePathOnDisk).
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)?