I have this page which upload an image. It works fine in one server that runs Windows Server 2003 / IIS6 but the same page runing on another server with Windows Server 2008 / IIS7 gives the following error message. Both servers are running Framework 4.0

Parameter is not valid. 
Description: An unhandled exception occurred during the execution of the current web request. Please review  
the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error: 


Line 38:         Dim streamImage As MemoryStream = New MemoryStream(byteImage)
Line 39:      
Line 40:         Dim bitmapImage As Bitmap = Bitmap.FromStream(streamImage)
Line 41: 
Line 42:           

This is a vb.net page
It get the image from a hidden file, send to stream and convert to bitmap

    Dim byteImage(1) As Byte
    byteImage = Convert.FromBase64String(hidImage.Value)
    Dim streamImage As MemoryStream = New MemoryStream(byteImage)
    Dim bitmapImage As Bitmap = Bitmap.FromStream(streamImage)

Hi, I'm using mssql 2008 and the following code works for me

Dim rawData() as Byte
fs = New FileStream("filelocation", FileMode.Open, FileAccess.Read)
                        Dim FileSize as Integer = fs.Length
                        rawData = New Byte(FileSize) {}
                        fs.Read(rawData, 0, FileSize)
fs.Close()

the "filelocation" is the full address like "C:/Pics/image.jpg" or "./Pics/image.jpg"
rawData is then added as a parameter to my dbCommand.

the datatype in my DB is image type

Hope this helps :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.