Click here to Skip to main content
15,891,863 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Error parameter not valid

VB
Private Sub ImageDisplay()

        Try
            PictureBox1.Image = Nothing
            Dim Scon As New SqlConnection("Data Source=xxx; Initial Catalog=xxx; Trusted_Connection=True; timeout = 100")
            Scon.Open()
            Dim Scom As New SqlCommand("Select datafrom table1 where id=2", Scon) 'to be updated
            Try

                Dim imageData As Byte() = DirectCast(Scom.ExecuteScalar(), Byte())

                If Not imageData Is Nothing Then
                    Using ms As New MemoryStream(imageData, 0, imageData.Length)
                        ms.Write(imageData, 0, imageData.Length)
                        newImage = Image.FromStream(ms, True)
                    End Using

                    PictureBox1.Image = newImage

                End If
            Catch ex As Exception
                MessageBox.Show(ex.Message)


            End Try

            Scon.Close()
        Catch ex As Exception
        Finally


        End Try

    End Sub



please help
Posted
Updated 3-Jun-15 2:10am
v2

1 solution

Spaces matter...
VB
Dim Scom As New SqlCommand("Select datafrom table1 where id=2", Scon) 'to be updated
Should be:
VB
Dim Scom As New SqlCommand("Select data from table1 where id=2", Scon) 'to be updated
 
Share this answer
 
Comments
Member 11014751 3-Jun-15 8:25am    
Thank you for reply but it does not work

Using ms As New MemoryStream(imageData, 0, imageData.Length)

In this line on ms it give the error below :
ReadTimeout = {"Timeouts are not supported on this stream."}
OriginalGriff 3-Jun-15 8:37am    
That's a different error altogether...
And probably needs a different question.
Are you sure this error is on the constructor?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900