Storing images in a Microsoft SQL Server 2005 database

Posted by Rekreativc on Stack Overflow See other posts from Stack Overflow or by Rekreativc
Published on 2010-05-17T09:47:09Z Indexed on 2010/05/17 9:50 UTC
Read the original article Hit count: 237

Filed under:
|
|

Hello!

I have a question about storing an image in a database. I know this topic has been discussed before, however I feel that in my case this is actually a good idea - the images will be small (none should be as large as 1MB) and there shouldn't be too many. I like the idea of not worrying about IO permissions etc.

Anyway I have a problem when storing the image (byte[]) to the database type image.

Here is my code:

OleDbCommand comm = new OleDbCommand(strSql, Program.GetConnection());

comm.Parameters.Add("?", SqlDbType.Image).Value = bytearr;

comm.ExecuteNonQuery();

Everything compiles fine, however when I run it, the code only saves the value 63 (0x3F) into the field - no matter which image I am trying to save.

What could be the problem? Thank you for your help.

© Stack Overflow or respective owner

Related posts about c#

Related posts about sqlserver2005