0

I am storing the image in a database and using c# as the front end.

I am storing the image by converting into binary format.

How can I retrieve the image stored in binary format from database?

1

1 Answer 1

1

Maybe this will help:

OdbcConnection con = new OdbcConnection(ConnectString);
con.Open();
OdbcCommand checkcommand = new OdbcCommand("SELECT contents FROM MyTable WHERE MyClause",  con);
OdbcDataReader checkreader = checkcommand.ExecuteReader();
byte[] array = null;
if (checkreader.Read())
    array = (byte[])checkreader.GetValue(0);
else
{
   //Error
   return false;
}

File.WriteAllBytes("C:\\MyImage.jpeg", array);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.