Storing images in a Microsoft SQL Server 2005 database
- by Rekreativc
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.