By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,694 Members | 1,320 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,694 IT Pros & Developers. It's quick & easy.

Convert image to byte

P: n/a
While dr.Read

form = dr("form")

Dim img As Image
Dim b() As Byte
b = form
If b.Length > 0 Then
Dim stream As New MemoryStream(b, True)
stream.Write(b, 0, b.Length)
* img = New Bitmap(stream)
stream.Close()
End If
End While

Now, I want to retrieve the form and displayed into the picturebox form
(form is one of my attributes in a table and its datatype is varbinary).
The form was inserted as a byte into the database. I have problem with
the above code. Does anyone know why? Thank you.

The below error occured at * statement.
An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Invalid parameter used.
:)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
i have a sample code here: http://thedeveloperscorner.com.ph
look for posting "Save and Retrieve Any File To Database"
it was written in C#, i hope somehow you can get an idea.
regards.

--
gani


"su see" <su******@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
While dr.Read

form = dr("form")

Dim img As Image
Dim b() As Byte
b = form
If b.Length > 0 Then
Dim stream As New MemoryStream(b, True)
stream.Write(b, 0, b.Length)
* img = New Bitmap(stream)
stream.Close()
End If
End While

Now, I want to retrieve the form and displayed into the picturebox form
(form is one of my attributes in a table and its datatype is varbinary).
The form was inserted as a byte into the database. I have problem with
the above code. Does anyone know why? Thank you.

The below error occured at * statement.
An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Invalid parameter used.
:)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #2

P: n/a
Hi,

I posted some code which converts images to and from byte.
http://www.gotdotnet.com/Community/U...3-c664ae2f91f8

Ken
----------------

"su see" <su******@hotmail.com> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
While dr.Read

form = dr("form")

Dim img As Image
Dim b() As Byte
b = form
If b.Length > 0 Then
Dim stream As New MemoryStream(b, True)
stream.Write(b, 0, b.Length)
* img = New Bitmap(stream)
stream.Close()
End If
End While

Now, I want to retrieve the form and displayed into the picturebox form
(form is one of my attributes in a table and its datatype is varbinary).
The form was inserted as a byte into the database. I have problem with
the above code. Does anyone know why? Thank you.

The below error occured at * statement.
An unhandled exception of type 'System.ArgumentException' occurred in
system.drawing.dll
Invalid parameter used.
:)

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.