473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

problem saving image to database

Hi all,

I'm trying to save a picturebox image to a database. This is part of the
code I'm using:-

<snip>
Private drv As DataRowView
Private dr As MainDataSet.OrdersRow

If PictureBox.Image IsNot Nothing Then
dr.Pic = CreateByteImage()
End If
<snip>

Private Function CreateByteImage() As Byte()
Dim ms As New IO.MemoryStream
PictureBox.Image.Save(ms, PictureBox.Image.RawFormat)

Dim arrImage() As Byte = ms.GetBuffer
ms.Close()

Return arrImage
End Function

The problem is it fails on the PictureBox.Image.Save line with the error -

Value cannot be null.
Parameter name: encoder

As far as I can tell I'm not passing a NULL reference, can anyone tell me
where I might be going wrong?

Thanks and kind regards,

Martin Horn
Jan 30 '06 #1
1 5411
I sorted it by changing the offending line to :-

PictureBox.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp)

I'm not entirely certain why I had to, or what problems it will cause me
later, but it works so...

Regards,

Martin.

"Martin Horn" <mv****@theinternet.com> wrote in message
news:eI*******************@newsfe3-gui.ntli.net...
Hi all,

I'm trying to save a picturebox image to a database. This is part of the
code I'm using:-

<snip>
Private drv As DataRowView
Private dr As MainDataSet.OrdersRow

If PictureBox.Image IsNot Nothing Then
dr.Pic = CreateByteImage()
End If
<snip>

Private Function CreateByteImage() As Byte()
Dim ms As New IO.MemoryStream
PictureBox.Image.Save(ms, PictureBox.Image.RawFormat)

Dim arrImage() As Byte = ms.GetBuffer
ms.Close()

Return arrImage
End Function

The problem is it fails on the PictureBox.Image.Save line with the error -

Value cannot be null.
Parameter name: encoder

As far as I can tell I'm not passing a NULL reference, can anyone tell me
where I might be going wrong?

Thanks and kind regards,

Martin Horn

Jan 30 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: rohith | last post by:
Hope someone can help with this question. I have a digital camera that will be used to capture photographs for picture ids. My question is whether I can capture the image from a web page...
2
by: Jeronimo Bertran | last post by:
Hello, I am using a rendering aspx page to display a database image on an Image control. When the database record is retrieved, I am saving the bitmap to a session variable for the rendering...
5
by: IkBenHet | last post by:
Hello, I use this script to upload image files to a folder on a IIS6 server: ******************* START UPLOAD.ASPX FILE ********************** <%@ Page Language="VB" Debug="true" %>
0
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
3
by: Tony Lugg | last post by:
I have an application with a document management form. When users add documents to the form, I call the API function SHGetFileInfo to get the associated large and small icons for the file. These...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
6
by: Mark Denardo | last post by:
My question is similar to one someone posted a few months back, but I don't see any replies. Basically I want to be able to have users upload photos and save them in a database (as byte data)...
2
by: keerthisreenu | last post by:
hai to all...!! iam working with Ms Access 2000. iam saving an image in the database. After that i want to retrive the same image from database and displaying it in the picture box. but its not...
10
by: Nathan Sokalski | last post by:
I am using ASP.NET 2.0, and need to know how to save and use an image that is stored in an SQL Server image datatype. How can I do this using ASP.NET? Thanks.
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.