S
Stephen
Hi,
is there any way to store image in access database. I know there is an image
datatype in SQL.
I am trying to make use of a piece of code to stream an image and then store
it in access
System.Byte[] FileByteArray = new System.Byte[FileLength];
System.IO.Stream StreamObject = UpFile.InputStream;
StreamObject.Read(FileByteArray,0,FileLength);
Here I am converting it into stream and then using this piece of code to
insert into the database
System.String SqlCmd = "INSERT INTO Images (Image, ContentType,
ImageDescription, ByteSize) VALUES (?, ?, ?, ?)";
System.Data.OleDb.OleDbCommand OleDbCmdObj = new
System.Data.OleDb.OleDbCommand(SqlCmd, Con);
OleDbCmdObj.Parameters.Add("@Image", System.Data.OleDb.OleDbType.Binary,
FileLength).Value = FileByteArray;
OleDbCmdObj.Parameters.Add("@ContentType",
System.Data.OleDb.OleDbType.VarChar,50).Value = UpFile.ContentType;
OleDbCmdObj.Parameters.Add("@ImageDescription",
System.Data.OleDb.OleDbType.VarChar,100).Value = txtDescription.Text;
OleDbCmdObj.Parameters.Add("@ByteSize",
System.Data.OleDb.OleDbType.VarChar,100).Value = UpFile.ContentLength;
the Insert fails and I think it because of the first commandparameter.
Please advice,
Stephen
is there any way to store image in access database. I know there is an image
datatype in SQL.
I am trying to make use of a piece of code to stream an image and then store
it in access
System.Byte[] FileByteArray = new System.Byte[FileLength];
System.IO.Stream StreamObject = UpFile.InputStream;
StreamObject.Read(FileByteArray,0,FileLength);
Here I am converting it into stream and then using this piece of code to
insert into the database
System.String SqlCmd = "INSERT INTO Images (Image, ContentType,
ImageDescription, ByteSize) VALUES (?, ?, ?, ?)";
System.Data.OleDb.OleDbCommand OleDbCmdObj = new
System.Data.OleDb.OleDbCommand(SqlCmd, Con);
OleDbCmdObj.Parameters.Add("@Image", System.Data.OleDb.OleDbType.Binary,
FileLength).Value = FileByteArray;
OleDbCmdObj.Parameters.Add("@ContentType",
System.Data.OleDb.OleDbType.VarChar,50).Value = UpFile.ContentType;
OleDbCmdObj.Parameters.Add("@ImageDescription",
System.Data.OleDb.OleDbType.VarChar,100).Value = txtDescription.Text;
OleDbCmdObj.Parameters.Add("@ByteSize",
System.Data.OleDb.OleDbType.VarChar,100).Value = UpFile.ContentLength;
the Insert fails and I think it because of the first commandparameter.
Please advice,
Stephen