I am recieving an error when I am trying to write a blob file to MySQL. Can anyone help me figure out what I am doing wrong.
Here is my code:
Code:
Dim ScreenFileSize As UInt32 = 0
Dim ScreenFile() As Byte
Dim ScreenStream As FileStream
ScreenStream = New FileStream(ScreenImageLocation, FileMode.Open, FileAccess.Read)
ScreenFileSize = ScreenStream.Length
ScreenFile = New Byte(ScreenFileSize) {}
ScreenStream.Read(ScreenFile, 0, ScreenFileSize)
ScreenStream.Close()
Try
MySQLQuery = "UPDATE " & MySQLDatabase & ".btt (ScreenShot) VALUES(?FileUpload) WHERE Ticket='" & strTicketNo & "'"
MySQLCommand = New MySql.Data.MySqlClient.MySqlCommand(MySQLQuery, MySQLConnection)
MySQLConnection.Open()
MySQLCommand.CommandText = MySQLQuery
MySQLCommand.Prepare()
MySQLCommand.Parameters.Clear()
MySQLCommand.Parameters.Add("?FileUpload", ScreenFile)
MySQLCommand.ExecuteNonQuery()
MySQLConnection.Close()
Catch ex As Exception
End Try
End If
Here is the first part of the error I recieve:
MySql.Data.MySqlClient.MySqlException was caught
ErrorCode=-2147467259
Message="You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(ScreenShot) VALUES(_binary 'ÿØÿà\0JFIF\0\0`\0`\0\0ÿÛ\0C\0
' at line 1"
Number=1064
Source="MySql.Data"