Skip to Content.
Sympa Menu

freetds - Re: Display Image Fields From MSSQL.

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Franck Martin <Franck AT sopac.org>
  • To: 'TDS Development Group' <freetds AT franklin.oit.unc.edu>
  • Subject: Re: Display Image Fields From MSSQL.
  • Date: Tue, 6 Mar 2001 12:07:31 +1200


Here is the php code that I use...

Note that this code removes the OLE container of the object. MS-Access store
the image in an ole container by default which get then stored in the binary
field... This php code looks for the beginning of the JPEG data by looking
for the string JFIF. The beginning is then a few characters before...

I hope it helps. It works for me... cf
http://www.sopac.org.fj/Data/Aerial/Snaps.html?setid=1

===========================
<%
Header("Content-type: image/jpeg");

$conn = sybase_pconnect("SERVER","username","password");
$ok=sybase_select_db("SOPACDB",$conn);
if (@$snapid==0)
{
$snapid=1;
}

$result = sybase_query("Snap_Image2vchar ".$snapid);
$nbrows=sybase_num_rows($result);


for ($i = 0 ; $i < $nbrows; $i++)
{
sybase_data_seek($result,$i);
$par = sybase_fetch_object($result);
if ($i==0)
{
// Needs to remove the OLE header if any...
$pos=strpos($par->Snap,"JFIF");
echo (substr($par->Snap,$pos-6));
} else
{
echo ($par->Snap);
}
}

%>
=========================

Franck Martin
Network and Database Development Officer
SOPAC South Pacific Applied Geoscience Commission
Fiji
E-mail: franck AT sopac.org <mailto:franck AT sopac.org>
Web site: http://www.sopac.org/
<http://www.sopac.org/> Support FMaps: http://fmaps.sourceforge.net/
<http://fmaps.sourceforge.net/>

This e-mail is intended for its addresses only. Do not forward this e-mail
without approval. The views expressed in this e-mail may not be necessarily
the views of SOPAC.



-----Original Message-----
From: Leo Kwan [mailto:leo_kwan AT hotmail.com]
Sent: Monday, 5 March 2001 4:47
To: TDS Development Group
Subject: [freetds] Re: Display Image Fields From MSSQL.


I hope this can help you.

CREATE PROCEDURE sp_Image2vchar
@ProductCode int
AS

DECLARE @Count int
Declare @Start int
Declare @NextLen int

select @Count = datalength(Cover) from product where
productcode=@ProductCode

select @NextLen = 4096
select @start = 1
create table #T (Cover text, NextLen int)
while (@Count > 0)
begin
if (select @count) < @nextlen
begin
select @NextLen = @count
end

insert into #T select
convert(text(4096),convert(varchar(4096),substring(Cover,@Start,@NextLen)))
as Cover, @Nextlen
as OutLength from Products where productcode = @ProducTCode

select @count = @count - @NextLen
select @Start =@start + @NextLen
end
select * from #t





Archive powered by MHonArc 2.6.24.

Top of Page