M
MS
I am storing an image in a datatable using the following code:
the dataset is created using oledb:
cmd = new OleDbCommand("SELECT * FROM StudentData " +
"WHERE RecordId=" + grdData.Rows[_RecordIdRowId].Cells["Value"].Text,
dbConn);
adapter = new OleDbDataAdapter(cmd);
dtStudent = new DataTable("Student");
adapter.Fill(dtStudent);
cmd = null;
adapter = null;
cmd = null;
adapter = null;
//define/add the column
DataColumn columname = dtStudent.Columns.Add("Image01", typeof(Image));
Put the image in the datatable
Bitmap bmp = new Bitmap(Common.gPic2LabPath + "Cropped\\" +
row["ImageName"].ToString().Trim());
dtStudent.Rows[0]["Image01" = bmp.Clone();
bmp.Dispose();
Dispose the datatable
dtStudent.Dispose();
If I try to rename the the image (on disk), I am told that another process
has it open.
Is there something else I need to do to release the image?
the dataset is created using oledb:
cmd = new OleDbCommand("SELECT * FROM StudentData " +
"WHERE RecordId=" + grdData.Rows[_RecordIdRowId].Cells["Value"].Text,
dbConn);
adapter = new OleDbDataAdapter(cmd);
dtStudent = new DataTable("Student");
adapter.Fill(dtStudent);
cmd = null;
adapter = null;
cmd = null;
adapter = null;
//define/add the column
DataColumn columname = dtStudent.Columns.Add("Image01", typeof(Image));
Put the image in the datatable
Bitmap bmp = new Bitmap(Common.gPic2LabPath + "Cropped\\" +
row["ImageName"].ToString().Trim());
dtStudent.Rows[0]["Image01" = bmp.Clone();
bmp.Dispose();
Dispose the datatable
dtStudent.Dispose();
If I try to rename the the image (on disk), I am told that another process
has it open.
Is there something else I need to do to release the image?