-1

Here is my code

    Dim Cmd As New OleDbCommand

    Dim strsql As String

    Try
        Dim fsreader As New FileStream(OpenFile.FileName, FileMode.Open, FileAccess.Read)
        Dim breader As New BinaryReader(fsreader)
        Dim imgbuffer(fsreader.Length) As Byte
        breader.Read(imgbuffer, 0, fsreader.Length)
        fsreader.Close()

        strsql = "UPDATE AccResult SET (PicFile, PicName) Values (@pfile, @pname) WHERE StudNo = '" & Form1.sNo.Text & "'"
        Cmd = New OleDbCommand(strsql, con)
        Cmd.Parameters.AddWithValue("@pfile", txtSave.Text)
        Cmd.Parameters.AddWithValue("@pname", imgbuffer)
        Cmd.ExecuteNonQuery()
        Cmd.Dispose()
    Catch ex As Exception

    End Try

please help me how can i update the students data when saving their picture in database. im using VB.NET. Thank You.

dbmitch
  • 5,361
  • 4
  • 24
  • 38
Aouie
  • 119
  • 2
  • 8
  • 17

1 Answers1

0

Looks like simple error in your logic - you have the filename reversed with the file content

Cmd.Parameters.AddWithValue("@pfile", txtSave.Text)
Cmd.Parameters.AddWithValue("@pname", imgbuffer)

Should be

Cmd.Parameters.AddWithValue("@pfile", imgbuffer)
Cmd.Parameters.AddWithValue("@pname", txtSave.Text)
dbmitch
  • 5,361
  • 4
  • 24
  • 38