freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "Leo Kwan" <leo_kwan AT hotmail.com>
- To: freetds AT franklin.oit.unc.edu
- Subject: Re: Display Image Fields From MSSQL.
- Date: Sun, 4 Mar 2001 23:46:43 -0500
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
=======================================
We cannot directly convert image data type to text type, so we have to
change it to varchar first and then convert it to text.
In php.
================
$ConnID = sybase_connect ("mssql","username","password");
$result = sybase_query("sp_image2vchar 1437");
$info = sybase_fetch_field($result);
echo "<BR>Type = ".$info->type;
echo "<BR>Max_length = ".$info->max_length;
echo "<BR>Name = ".$info->name;
$rows = sybase_num_rows($result);
echo "<BR>Total rows = ".$rows;
$par = sybase_fetch_object($result);
echo "<BR> Par Type = ".$par;
$fp = fopen ("/var/www/html/temp/hoho.gif","wb");
for ($i = 0 ; $i < $rows; $i++)
{
sybase_data_seek($result,$i);
$par = sybase_fetch_object($result);
echo "<BR>$i = ".$par->NextLen;
echo fwrite ($fp,$par->Cover,$par->NextLen);
}
fclose ($fp);
===================
The file in /var/www/html/temp/hoho.gif is what you get from MSSQL.
-
Display Image Fields From MSSQL.,
Leo Kwan, 03/03/2001
- <Possible follow-up(s)>
- Re: Display Image Fields From MSSQL., Brian Bruns, 03/03/2001
- Re: Display Image Fields From MSSQL., Steve Langasek, 03/04/2001
- Re: Display Image Fields From MSSQL., Brian Bruns, 03/04/2001
- Re: Display Image Fields From MSSQL., Bob Kline, 03/04/2001
- Re: Display Image Fields From MSSQL., Leo Kwan, 03/04/2001
- Re: Display Image Fields From MSSQL., Leo Kwan, 03/04/2001
- Re: Display Image Fields From MSSQL., Franck Martin, 03/04/2001
- Re: Display Image Fields From MSSQL., Leo Kwan, 03/04/2001
- Re: Display Image Fields From MSSQL., Michael Peppler, 03/05/2001
- Re: Display Image Fields From MSSQL., Bob Kline, 03/05/2001
- Re: Display Image Fields From MSSQL., Michael Peppler, 03/05/2001
- Re: Display Image Fields From MSSQL., Brian Bruns, 03/05/2001
- Re: Display Image Fields From MSSQL., Franck Martin, 03/05/2001
- Re: Display Image Fields From MSSQL., Leo Kwan, 03/06/2001
- Re: Display Image Fields From MSSQL., Franck Martin, 03/07/2001
Archive powered by MHonArc 2.6.24.