Hello guys, I made a simple program that Add, Saves, Edit & Retrieves Data from a MS Access DB...

 Dim arrImage() As Byte
                Dim strImage As String

                If Not IsNothing(Me.ImageBox.Image) Then
                    Me.ImageBox.Image.Save(myMs, Me.ImageBox.Image.RawFormat)
                    arrImage = myMs.GetBuffer
                    strImage = "?"

                Else
                    arrImage = Nothing
                    strImage = "NULL"

                End If

                myqry = "UPDATE arms SET "
                myqry = myqry + " RealID = '" & box_realid.Text & "',"
                myqry = myqry + " Locale = '" & box_locale.Text & "',"
                myqry = myqry + " Lastname = '" & box_lastname.Text & "',"
                myqry = myqry + " Middle_Initial = '" & box_middleintl.Text & "',"
                myqry = myqry + " Firstname = '" & box_firstname.Text & "',"
                myqry = myqry + " Address = '" & box_address.Text & "',"
                myqry = myqry + " Birthday = '" & box_birthday.Text & "',"
                myqry = myqry + " Picture = '" & strImage & "'" <----- THE IMAGE....
                myqry = myqry + " WHERE "
                myqry = myqry + " ID = " & box_databaseid.Text

                mycmd = New OleDbCommand(myqry, conn)

                If strImage = "?" Then
                    mycmd.Parameters.Add(strImage, OleDb.OleDbType.Binary).Value = arrImage
                End If

                mycmd.ExecuteNonQuery()

well the problem is that, everytime I change the image, it give's me "Parameter is not valid." when I retrieve the picture, and also if I edit some of the information, it also gives me error when i retrieve, does anyone know how to fix this? please help me.. im stuck in this part.. Im still learning on VB..

I also tried making a guessed solution by mixing the myqry below

                myqry = "UPDATE arms SET "
                myqry = myqry + " RealID = '" & box_realid.Text & "',"
                myqry = myqry + " Locale = '" & box_locale.Text & "',"
                myqry = myqry + " Lastname = '" & box_lastname.Text & "',"
                myqry = myqry + " Middle_Initial = '" & box_middleintl.Text & "',"
                myqry = myqry + " Firstname = '" & box_firstname.Text & "',"
                myqry = myqry + " Address = '" & box_address.Text & "',"
                myqry = myqry + " Birthday = '" & box_birthday.Text & "'"
                myqry = "UPDATE arms SET " + " Picture = " & strImage  <------ Image is now working...
                myqry = myqry + " WHERE "
                myqry = myqry + " ID = " & box_databaseid.Text

for now, everytime I retrieve the image, it does not give me a parameter error and the Image also changes, BUT when i change the information, e.g the Name and save it, it does not change... please help me fix this.. Thanks!

It looks like it is trying to update a parameter that has no data. are you filling the Picture value with Null if the strImage is Nothing? I would create a new variable that is value of Null when Image is empty or is nothing.

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.