How to save iamge in database?

  • Thread starter Ishtiaque Ahmed Memon
  • Start date
I

Ishtiaque Ahmed Memon

Dear All

Can anyone tell me how to save an JPEG image in a database table field?

Below is the code that I have wrote but it gives an error:
System.InvalidCastException
Object must implement IConvertible

DatabaseAccess.SqlConnection.Open()

picDataAdapter.InsertCommand = New SqlCommand("INSERT INTO TheImage(AppNo,
theImage) VALUES(@appno, @theImage)", DatabaseAccess.SqlConnection)

picDataAdapter.InsertCommand.Parameters.Add("@appno", SqlDbType.Int).Value =
AppNo

picDataAdapter.InsertCommand.Parameters.Add("@theImage", SqlDbType.Image,
7000).Value = MyImage

picDataAdapter.InsertCommand.ExecuteNonQuery()

DatabaseAccess.SqlConnection.Close()

TheImage table has two fields:

AppNo int

theImage Image

myImage is of Image type

Waiting for reply... Thanks in advance

Regards

Ishtiaque Ahmed Memon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top