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
2002
I 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 program
private 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.
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!