Hi,

I've got a column in a table which contains images (bmp
and jpg, i guess sql server don't convent the jpg to
bmp??).

How can I extract these images from the table.
I've tried something with a MemoryStream, but I don't know
how to save it to a file because this stream is a byte
array and I can't check the file type and other stuff like
that.

Is there anybody with the same problem?

Thanks a lot

Filip

Re: Extract images from sql server by Sergey

Sergey
Tue Oct 28 02:26:02 CST 2003

This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C39D3D.E330FBF0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

.......................
Type type =3D Table.Rows[0]["bitmap"].GetType();
System.Byte[] buf =3D Table.Rows[0]["bitmap"] as Byte[];

SaveFileDialog saveFileDialog1 =3D new SaveFileDialog();
if(saveFileDialog1.ShowDialog() =3D=3D DialogResult.OK)
{
FileStream fs =3D new FileStream(saveFileDialog1.FileName, =
FileMode.Create, FileAccess.Write);
BinaryWriter bw =3D new BinaryWriter(fs);
bw.Write(buf);
bw.Close();
fs.Close();
}

.................................
This code worked in my case.

Best regards,
Sergey Ivasenko.


"Filip De Backer" <filip.debacker@lessius-ho.be> wrote in message =
news:0a8901c39d2b$38104210$a101280a@phx.gbl...
> Hi,
>=20
> I've got a column in a table which contains images (bmp=20
> and jpg, i guess sql server don't convent the jpg to=20
> bmp??).
>=20
> How can I extract these images from the table.
> I've tried something with a MemoryStream, but I don't know=20
> how to save it to a file because this stream is a byte=20
> array and I can't check the file type and other stuff like=20
> that.
>=20
> Is there anybody with the same problem?
>=20
> Thanks a lot
>=20
> Filip
------=_NextPart_000_001B_01C39D3D.E330FBF0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>.......................</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Type type =3D=20
Table.Rows[0]["bitmap"].GetType();</FONT></DIV><FONT face=3DArial =
size=3D2><FONT=20
size=3D1>
<DIV></FONT>System.Byte[]&nbsp;buf =3D Table.Rows[0]["bitmap"] as=20
Byte[];</FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT face=3DArial><FONT =
size=3D2><FONT=20
face=3DArial><FONT size=3D2><FONT face=3DArial=20
size=3D2></FONT></FONT></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>SaveFileDialog saveFileDialog1 =3D new=20
SaveFileDialog();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>if(saveFileDialog1.ShowDialog() =3D=3D=20
DialogResult.OK)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>{</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; FileStream fs =3D =
new=20
FileStream(saveFileDialog1.FileName, FileMode.Create,=20
FileAccess.Write);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; BinaryWriter bw =3D =
new=20
BinaryWriter(fs);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
bw.Write(buf);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
bw.Close();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp; =
fs.Close();</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>.................................</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This code worked in my =
case.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Best regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Sergey Ivasenko.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>"Filip De Backer" &lt;</FONT><A=20
href=3D"mailto:filip.debacker@lessius-ho.be"><FONT face=3DArial=20
size=3D2>filip.debacker@lessius-ho.be</FONT></A><FONT face=3DArial =
size=3D2>&gt; wrote=20
in message </FONT><A =
href=3D"news:0a8901c39d2b$38104210$a101280a@phx.gbl"><FONT=20
face=3DArial =
size=3D2>news:0a8901c39d2b$38104210$a101280a@phx.gbl</FONT></A><FONT=20
face=3DArial size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt; =
Hi,<BR>&gt;=20
<BR>&gt; I've got a column in a table which contains images (bmp =
<BR>&gt; and=20
jpg, i guess sql server don't convent the jpg to <BR>&gt; =
bmp??).<BR>&gt;=20
<BR>&gt; How can I extract these images from the table.<BR>&gt; I've =
tried=20
something with a MemoryStream, but I don't know <BR>&gt; how to save it =
to a=20
file because this stream is a byte <BR>&gt; array and I can't check the =
file=20
type and other stuff like <BR>&gt; that.<BR>&gt; <BR>&gt; Is there =
anybody with=20
the same problem?<BR>&gt; <BR>&gt; Thanks a lot<BR>&gt; <BR>&gt;=20
Filip</FONT></BODY></HTML>

------=_NextPart_000_001B_01C39D3D.E330FBF0--