Re: How to extract an OLE Object (Bitmap Image) from JET?
- From: "deko" <deko@xxxxxxxxxx>
- Date: Mon, 11 Jul 2005 23:53:13 GMT
> For your example, MemoryStream is a standard .NET class; see
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemiomemorystreamclasstopic.asp .
>
> You will also find many exemple on the internet where the images are
> extracted from the database in chunks (blocks) instead of being retrieved
> in a single step. See
> http://support.microsoft.com/default.aspx?scid=kb;EN-US;317034 for
> example. It should be very easy to adapt this procedure to first read a
> chunk of 78 bytes and then drop it.
Thanks - that helps. I'm kind of a newbie, but I've got this far:
class GetImage
{
private System.Data.OleDb.OleDbConnection oleDbCnx;
private System.Data.OleDb.OleDbCommand oleDbCmd;
public GetImage(string artName)
{
oleDbCnx = new OleDbConnection();
oleDbCnx.ConnectionString =
("Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
+ Application.StartupPath + @"\DrinkMateImages.mdb");
string strSql = "SELECT Photo FROM Photos WHERE ArtworkName = "
+
artName;
oleDbCmd = new OleDbCommand(strSql, oleDbCnx);
}
private bool ToTempDir()
{
MemoryStream ms = new MemoryStream();
int offset = 78;
oleDbCnx.Open();
byte[] img = (byte[])oleDbCmd.ExecuteScalar();
ms.Write(img, offset, img.Length - offset);
oleDbCnx.Close();
Bitmap bmp = null;
bmp = new Bitmap(ms);
//how to get temp Dir?
bmp.Save("C:\temp", ImageFormat.Bmp);
ms.Close();
oleDbCnx.Close();
return true;
}
}
}
.
- References:
- How to extract an OLE Object (Bitmap Image) from JET?
- From: deko
- Re: How to extract an OLE Object (Bitmap Image) from JET?
- From: Sylvain Lafontaine
- Re: How to extract an OLE Object (Bitmap Image) from JET?
- From: deko
- Re: How to extract an OLE Object (Bitmap Image) from JET?
- From: Sylvain Lafontaine
- How to extract an OLE Object (Bitmap Image) from JET?
- Prev by Date: Re: Serialized object to XmlDocument
- Next by Date: Re: Sharing Data between apps
- Previous by thread: Re: How to extract an OLE Object (Bitmap Image) from JET?
- Next by thread: creating custom Excel functions
- Index(es):
Relevant Pages
|