473,412 Members | 2,050 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,412 software developers and data experts.

invalid parameter userd error.......

Hi

I am storing images in an access database, based on an MSDN article.
The code i use to store is as follows:

<code>

'Create the command object
Dim command As New OleDbCommand("ImageBlobUpdate", dataConnection)
Command.CommandType = CommandType.StoredProcedure)

'Get the byte array from the posted file
Dim stream As IO.Stream = sourceFile.ImputStream ' sourceFile is a
HttpPostedFile object
Dim bytes(Cint(stream.Length() - 1)) As Byte
stream.Read(bytes, 1, bytes.Length)
stream.Close

'Update the record
command.Parameters.Add("id", id)
Dim parameter As New OleDbParameter("[Image]"),
OleDbType.LongVarBinary, bytes.Length, ParameterDirection.Imput,
False, 0, 0, Nothing, DataRowVersion.Current, bytes)
command.Parameters.Add(parameter)
command.ExecuteNonQuery

</code>

This updates the database fine. I then use the following code to
extract it and convert it to the image:

<code>

'Get a reader containing the image data
Dim command As New OleDbCommand("ImageBlobSelect", dataConnection)
Command.CommandType = CommandType.StoredProcedure)
command.Parameters.Add("id", id)
Dim reader As OleDbDataReader = command.ExecuteReader

'Get the image from the reader
If reader.HasRows Then
reader.Read
Dim bytes(CInt(reader.GetBytes(0, 0, Nothing, 0, Integer.MaxValue)
- 1)) As Byte
reader.GetBytes(0, 0, bytes, 0, bytes.Length)
Dim stream As New IO.MemoryStream(bytes, 0, bytes.Length)
Dim image As System.Drawing.Image =
System.Drawing.Image.FromStream(stream)
End If

'Tidy Up
reader.Close

</code>

When running the code, the error 'Invalid parameter used' is occurs on
the line:

Dim image As System.Drawing.Image =
System.Drawing.Image.FromStream(stream)

If i simply write the stream to file, then the file that is created is
the same size as the original image, however it cannot be viewed in
any editor.

The original image is a .JPG.

Any ideas greatly appreciated, I have searched and most solutions
relate to the image header offset, but i do not think this is the
issue.

Cheers

jaffar

Dec 15 '06 #1
0 1080

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

Similar topics

9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
8
by: Owen Jenkins | last post by:
Hello. For years I've been using the DBEngine.CompactDatabase code to make backups of backend databases. But now I've struck a baffling problem where I get an Invalid Argument error. This...
0
by: David Veeneman | last post by:
This post is for the Google archive and does not require a reply. I received an 'Invalid parameter used' error when trying to do double-buffering with the .Net SetStyles method. I used this code...
1
by: Andy G | last post by:
I've been getting this error all day. Could someone please look at my stored procedure and the code. I have a form that grabs and email address the user types in, calls a stored procedure with an...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
3
by: Arnold | last post by:
I am having problem loading the image from the database. It gives this error: "Invalid parameter used." This is my source code: Private abyt() As Byte Private fo As New OpenFileDialog Private sf...
4
by: escristian | last post by:
Hello. I'm trying to create an Image so I use something like this: Image newImage = Image.FromFile(filename); Now when it's a bmp file and certain .gif files it gives me an exception that...
8
by: Lambda | last post by:
When I call the standard strncpy function, I provide it a negative argument, such as: strncpy(s, ct, -1) I compile the code with gcc, when I run, it says "Segmentation fault". Do you think...
2
by: Barry | last post by:
The problem brought by one earlier post from comp.lang.c++ http://groups.google.com/group/comp.lang.c++/browse_thread/thread/bf636c48b84957b/ I take part of the question and reproduce the code to...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.