problem to insert an image into a database using programatically

  • 11 years ago

    Hi everyone

    I am trying to insert an image into a database table field using sqlCommand object method ExecuteNonQuery().  My SQL statement has a parameter to assign the image. I keep getting an error saying "the object need to implement IConvertable". I don't know why?

    any help !

    'i wrote like this.........

    sql = "UPDATE tablename SET field1 = @image"

    dim picture as image = picturebox1.image


        SqlCommand(sql, cn)

       Dim par As New SqlParameter("@picture", SqlDbType.Image)

       par.Value = picture



    Catch e As InvalidCastException


    End try

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.” - Donald Knuth