Click here to Skip to main content
15,914,074 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to insert an image into a sqldatabse using vb.net. I have used the same concept to insert data into database and it worked but when i try to insert image using the same concept then my program says "Fatal error occurred during command execution". Can someone advise me how i can fix the error?

VB
 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString =
"server=localhost;userid=***;password=*******;database=database3"
        Dim READER As MySqlDataReader
        Try

            MysqlConn.Open()
            Dim Query As String
            Query = "Insert into database3.trial (id,Image) values ( '" & TextBox1.Text & "', @Image)"
            COMMAND = New MySqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader

            MessageBox.Show("DATA SAVED")



            MysqlConn.Close()
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
        Finally
            MysqlConn.Dispose()
        End Try
    End Sub
Posted

1 solution

You didn't add and set the @Image parameter. And while you're at it, use a parameter for the id as well.
 
Share this answer
 
Comments
Surajit Das 7-Feb-15 13:32pm    
@PEIBALDconsult:- I dint get you. Could you please elaborate a bit? Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900