Store bitmap data into sqlce database

  • Thread starter Thread starter Michael Morisoli
  • Start date Start date
M

Michael Morisoli

I am trying to find out if it is possable to store a bitmap into a sqlce
database.

I have created a test table with a few columns, one of which is an Image
type.

For the life of me I can not find a way to store the bitmap into the
database. Here is what I am doing that is raising InvalidCastException
errors.

try
string sql = "Insert Into Signatures (PackageGUID, SignedByEmployeeGUID,
Image) Values (?, ?, ?)";
SqlCeCommand cmd = GetCommand();
cmd.CommandText = sql;
cmd.Parameters.Add("@PackageGUID", PackageGUID);
cmd.Parameters.Add("@SignedByEmployeeGUID", SignedByEmployeeGUID);
cmd.Parameters.Add("@Image", SignatureBitmap);
count = cmd.ExecuteNonQuery();
}
catch (SqlCeException sqlex)
{
//retval = false;
HandleError(sqlex);
}
catch (Exception ex)
{
HandleError(ex);
}
finally
{
Close();
}

Thanks, Mike
 
Hi,

I have managed to store bitmap to sqlce database thru a dataset. In case of
dataset, u have to open the bitmap file, transfer the contents to byte array
and assign the byte array to the field object in the dataset.

Hope this helps...

Girish.
 
Back
Top