I AM WORKING ON A PROJECT IN WHICH I AM SAVING AN IMAGE IN ACCESS DATABASE,RETRIEVING THE IMAGE,UPDATING THE IMAGE AND THEN WHEN I TRY TO RETRIRVE THE UPDATED IMAGE I GET AN ERROR "PARAMETER IS NOT VALID"

SO PLZ POST THE CODE FOR UPDATING
PLS REPLY SOON ITS URGENT

Please post your code what you have so far so that people can see and help you on that.

'the code to save

 Dim cmd As New OleDbCommand(String.Format("insert into 1styear values ({0},'{1}','{2}','{3}','{4}',{5},{6},'{7}','{8}','{9}','{10}',@photo)", txtId.Text, txtName.Text, txtFname.Text, txtMname.Text, txtAdd.Text, txtNo.Text, txtphne.Text, txtdate.Text, DateTimePicker1.Text, txtAge.Text, txtMail.Text), LoginForm1.cn.con)
            Dim ms As New MemoryStream()
            PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
            Dim arrImage() As Byte = ms.GetBuffer
            ms.Close()
            ' Dim cm As New OleDbCommand(String.Format("insert into 1styear values(@photo)"), LoginForm1.cn.con)
            cmd.Parameters.Add(New OleDbParameter("@Photo", _
         OleDbType.VarBinary)).Value = arrImage


'the code to search

   Dim cmd1 As New OleDbCommand(String.Format("SELECT photo FROM 2ndyear WHERE ID=" & txtId.Text), LoginForm1.cn.con)

                    Dim reader As OleDbDataReader
                    reader = cmd1.ExecuteReader

                    If reader.Read Then
                        Dim imgByteArray() As Byte

                        Try
                            imgByteArray = CType(reader(0), Byte())
                            Dim stream As New MemoryStream(imgByteArray)
                            Dim bmp As New Bitmap(stream)
                            PictureBox1.Image = bmp
                            stream.Close()
                            'Return bmp
                        Catch ex As Exception
                            MessageBox.Show(ex.Message)
                            'Return Nothing
                        End Try
                    End If

                    reader.Close()
                    LoginForm1.cn.con.Close()

                    cmd1.Dispose()
                    LoginForm1.cn.con.Dispose()
                Catch ex As Exception
                    MessageBox.Show(ex.Message)
                    'Return Nothing
                End Try





                'the code to update

                   Dim cmd As OleDbCommand = New OleDbCommand("Update 1styear set photo=@photo where ID=" & txtId.Text, con.con)
 Dim ms As New MemoryStream()
            PictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)
            Dim arrImage() As Byte = ms.GetBuffer
            ms.Close()
            cmd.Parameters.Add(New OleDbParameter("@Photo", _
        OleDbType.VarBinary)).Value = arrImage






'with respect to this 3 codes image is saved properly retrieved properly 
'during updation message is recieved yhat updated successfully
'bt when i try to retrieve the updated image
'error is occured parameter is not valid
This article has been dead for over six months. Start a new discussion instead.