New problem with this. Yes I can store an image in a base64Binary column,
but when I'm stepping through the code and watching the values of variables
in the watch window, as soon as I assign the image to the dataset column,
the watch window says for the dataset: "Unable to evaluate expression".
Foe example, the text below was copied from the watch window. I put
ds.getxml as a watch:
ds.getxml "<dsCachedImages
xmlns="http://tempuri.org/dsCachedImages.xsd">
<tbImages>
<SessionID>hefuapb3rcwuzn45fzgeybml</SessionID>
<ImageId />
</tbImages>
</dsCachedImages>" String
then as soon as I assign the image, or rather the byte() variable holding
the image this is what I see in the watch window:
ds.getxml Unable to evaluate expression.
Actually the dataset is still OK as I can retrieve data from the dataset
including the image's byte array. But from this point forward I cant see
into it from the watch window. furthermore, when I get errors, along with
the error information I also record the dataset's contents into the error
log using .getxml so I can see what the data looked like at the time of the
error. now that ds.getxml can not be evaluated, I can't record its contents
into the error log. I also tried converting the byte() into a string and
saving it to a string column in the dataset and got the same result. This is
how I did that:
Dim str As String = System.Text.Encoding.Default.GetString(abytBuffer)
and this is what the string looked like in the watch window:
str "ÿØÿá#uExif String
so I appears that the string is still some of binary data which is confusing
the datase. I expected to get a much larger sting for an image 3k in size.
Is there a way to save an image to a dataset and still be able to use
ds.getxml on the dataset?
--
mo*******@nospam.com
"moondaddy" <mo*******@nospam.com> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl...
Thanks! Thats exactly what I needed.
--
mo*******@nospam.com
"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com... Define datacolumn with XSD data type base64Binary to store image
"moondaddy" wrote:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My
problem is that I don't know how to get the image into the dataset because I
don't know what datatype to set the dataset column and then set this image to. I saw an example where someone defended a datatable in the global class and
defined the column as an object, however, when I define a strongly
typed dataset in the IDE there's no data type called object, binary, or
byte().
For a start, here's how I'm getting the image data from the user
(ImageFileField is an inupt element type 'File' in the aspx):
Dim strm As Stream
strm = ImageFileField.PostedFile.InputStream
Dim lngLen As Long = strm.Length
Dim abytBuffer(CInt(lngLen - 1)) As Byte
strm.Read(abytBuffer, 0, CInt(lngLen))
So from here I have a memorystream object and a byte array both with
the image data. So now what do I do?
Thanks.
--
mo*******@nospam.com