CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Threaded View

  1. #1
    Join Date
    Feb 2009
    Posts
    18

    BLOB & MySQL problem

    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"
    Last edited by Shuja Ali; March 17th, 2009 at 02:07 PM. Reason: Added Code Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured