How To Update Image ?

arshafieen

New member
Joined
May 16, 2013
Messages
3
Programming Experience
Beginner
I've tried using this code but don't what wrong with this code..

My Coding
Private Sub lblsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblsave.Click
con.Open()
str = "update cpkStaff set Image = @myimage where StaffID = @id"

With cmd.Parameters

Try
Dim ms As New System.IO.MemoryStream
Dim bmpImage As New Bitmap(PictureBox1.Image)

bmpImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
bytImage = ms.ToArray()
ms.Close()
Catch ex As Exception
MsgBox(ex.ToString)
End Try

.AddWithValue("@myimage", bytImage)
.AddWithValue("@id", cpk2main.txtid.Text)

End With
cmd = New SqlCommand(str, con)
cmd.ExecuteNonQuery()
MessageBox.Show("Admin's account was successfully updated!", "INFO", MessageBoxButtons.OK, MessageBoxIcon.Information)
con.Close()
End Sub

PROBLEM
11.jpg12.jpg

Some can help solve this problem.. i need it coz next month i've presentation
 
Consider this. If you have a piece of paper and you write something on it, then you get a new piece of paper, would you expect the writing to be on the new piece of paper? Of course you wouldn't, but that's basically what you're doing. You're adding the parameters to your command and then you create a new command and execute it. You might try creating your command first, then adding the parameters.
 
Back
Top