Re: How to extract an OLE Object (Bitmap Image) from JET?



> 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;
}
}
}


.



Relevant Pages

  • Re: drawbacks of Saving documents to Sql server
    ... I have never done virus scan on them. ... Since the file is really just a binary array divided into big chunks, you can get the chunks from the database as byte arrays and use Response.BinaryWrite for the arrays. ... >> webservices application\ webforms applicatoin to sql server 2000. ...
    (microsoft.public.dotnet.framework)
  • Compound files, but not Microsofts
    ... relatively small chunks of data, ... Built-in compression and encryption on the fly would be nice, ... a database has lots of features I don't need and I am not using DB-aware ... No ads, no nags freeware: http://www.tranglos.com ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Help needed in transfering or backing up/restoring Informix database via ODBC.
    ... the majority of all tools and their subsequent ... the database is online simply due to the ... Now if I could use the raw chunks from the good drive, ... virtually the same hardware online, I'm exporting all the data to SQL ...
    (comp.databases.informix)
  • Re: Client Server shared folder/file upload (security)
    ... I would split up the files into 64K chunks and send them in byte arrays to a web service and insert them into a staging tables in the database. ... my server code would "commit" the data in the staging tables to the production tables. ... client, so they can't see database connection and other setting. ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: Problem exporting data
    ... In this dbspace i have 4 chunks of 2Gb each one. ... want to replicate this database in another disk. ... Dimitar Bachvarov begin:vcard ...
    (comp.databases.informix)