Skip to content
Advertisement

issue in saving image to mysql database . Program is running perfectly with no errors

Advertisement

Answer

This is wrong:

You are mixing and matching two different ways of adding parameters. If you call AddWithValue (which you generally should not) then you need to provide a value, not a type. If you’re going to specify a type and then set the Value afterwards then you call Add.

Also, SqlDBType is for SqlClient and SQL Server. If you’re using MySqlClient and MySQL then you need to use MySqlDbType. That’s a perfect example of why you need Option Strict On right there.

Your code should be something like this:

I say “something like this” because what type you specify depends on the actual data type you used in the database. If you need to use VarBinary then you should also specify a size.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement