Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jani
Starting Member
2 Posts |
Posted - 2004-08-18 : 12:54:15
|
I am trying to retrieve images from SQL server and display them on the client’s browser. Images in the SQL server are imported from MS Access 2002I found the following code that mentions about removing the OLE Header for Northwind Database. I tried using the same logic to retrieve images from the database that I imported and got an error “Invalid parameter” when trying to run the programprivate void DisplayImages (){ string connectionString = "workstation id=\"GA33611-PDD\";user id=sa;password=dufas;data source=\"GA33611-PDD" + "\";initial catalog=northwind";SqlConnection cn = new SqlConnection(connectionString); SqlCommand cmd = new SqlCommand(cmdText, cn); MemoryStream ms = new MemoryStream();// 78 is the size of the OLE header for Northwind images. // There's no header in PUBS as PUBS // just contains the raw image bits. int offset = 78; cn.Open(); byte [] img = (byte[]) cmd.ExecuteScalar(); ms.Write(img, offset, img.Length-offset); cn.Close(); Bitmap bmp = null; bmp = new Bitmap(ms); Response.ContentType = "image/gif";bmp.Save(Response.OutputStream, ImageFormat.Gif); ms.Close(); }As I think may be I need to remove that OLE header in my database. Are there any ways to find out the size of this header. Any help in this regard is greatly appreciated.Thank you |
|
ehorn
Master Smack Fu Yak Hacker
1632 Posts |
|
|
|
|