Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Displaying image data from SQL...single/multipart tiff

Reply
Thread Tools

Displaying image data from SQL...single/multipart tiff

 
 
CD
Guest
Posts: n/a
 
      07-07-2006
An application is logging faxes sent in SQL2000 image column type. I have
found code on the net but what it is doing is prompting to save to local
which is fine for single page image. Not good for multiple page faxes. I
have not been able to locate an example to load in the browser or how to
handle multiple image in the one column.

1) Ideally it would be nice to display back in the browser since some may be
multiple images. I am not a programmer but any help is appreciated..

<%
Dim strAttachID
strAttachID = Request.QueryString("AttachID")

Dim objConn, objRS, strSQL

adoconnectstr = "Driver={SQL
Server};database=faxmakerarchive;Server=XXXX;uid=X XXX;pwd=XXX;CommandTimeout
= 180"
set objCon = server.CreateObject("ADODB.Connection")
set objRec = server.CreateObject("ADODB.Recordset")

objCon.Open adoconnectstr
strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
"'"
objrec.Open strSQL, objCon

Response.ContentType = "image/tiff"
'Response.ContentType = "application/pdf"

Response.BinaryWrite objrec("attdata")

objrec.Close
Set objrec = Nothing
objCon.Close
Set objCon = Nothing
%>

TIA!!


 
Reply With Quote
 
 
 
 
Mark J. McGinty
Guest
Posts: n/a
 
      07-09-2006

"CD" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> An application is logging faxes sent in SQL2000 image column type. I have
> found code on the net but what it is doing is prompting to save to local
> which is fine for single page image. Not good for multiple page faxes. I
> have not been able to locate an example to load in the browser or how to
> handle multiple image in the one column.
>
> 1) Ideally it would be nice to display back in the browser since some may
> be multiple images. I am not a programmer but any help is appreciated..
>
> <%
> Dim strAttachID
> strAttachID = Request.QueryString("AttachID")
>
> Dim objConn, objRS, strSQL
>
> adoconnectstr = "Driver={SQL
> Server};database=faxmakerarchive;Server=XXXX;uid=X XXX;pwd=XXX;CommandTimeout
> = 180"


First, you should use the OLEDB provider instead of ODBC. (Use
"Provider=SQLOLEDB;" in place of "Driver=...")


> set objCon = server.CreateObject("ADODB.Connection")
> set objRec = server.CreateObject("ADODB.Recordset")
>
> objCon.Open adoconnectstr
> strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
> "'"
> objrec.Open strSQL, objCon
>
> Response.ContentType = "image/tiff"
> 'Response.ContentType = "application/pdf"
>
> Response.BinaryWrite objrec("attdata")


Does that work? I use this:

Set s = Server.CreateObject("ADODB.Stream")
s.Mode = 3
s.Type = 1
s.Open

// write the contents of the blob field to the stream
s.Write objrec("attdata").Value
s.Position = 0

Response.ContentType = "image/tiff"
Response.BinaryWrite s.Read()

You can reuse the stream, just close it and open it again to clear it.

As for multiple images in the same blob, that's a tough one... when you save
a multi-page blob to file, can the file be opened in a normal image viewer?
Maybe it's a single image that spans multiple logical pages? If not, and
multiple image file structures are written to the field back-to-back, you'll
have to separate the images by searching for the file header, signature, or
some other unique feature with which the start of each image might be
located. (It would be much easier to write each image to a different row,
and associate those rows that go together, if you have any control over that
end.)

Given you're able to get valid images out of it, one approach to displaying
multiple pages would be to generate an HTML document with multiple image
tags, one for each page.


-Mark



> objrec.Close
> Set objrec = Nothing
> objCon.Close
> Set objCon = Nothing
> %>
>
> TIA!!
>



 
Reply With Quote
 
 
 
 
CD
Guest
Posts: n/a
 
      07-10-2006
yes the above works. That is what i am guessing the application is placing
multi image in one row.

thanks for the reply

"Mark J. McGinty" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "CD" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> An application is logging faxes sent in SQL2000 image column type. I
>> have found code on the net but what it is doing is prompting to save to
>> local which is fine for single page image. Not good for multiple page
>> faxes. I have not been able to locate an example to load in the browser
>> or how to handle multiple image in the one column.
>>
>> 1) Ideally it would be nice to display back in the browser since some may
>> be multiple images. I am not a programmer but any help is appreciated..
>>
>> <%
>> Dim strAttachID
>> strAttachID = Request.QueryString("AttachID")
>>
>> Dim objConn, objRS, strSQL
>>
>> adoconnectstr = "Driver={SQL
>> Server};database=faxmakerarchive;Server=XXXX;uid=X XXX;pwd=XXX;CommandTimeout
>> = 180"

>
> First, you should use the OLEDB provider instead of ODBC. (Use
> "Provider=SQLOLEDB;" in place of "Driver=...")
>
>
>> set objCon = server.CreateObject("ADODB.Connection")
>> set objRec = server.CreateObject("ADODB.Recordset")
>>
>> objCon.Open adoconnectstr
>> strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
>> "'"
>> objrec.Open strSQL, objCon
>>
>> Response.ContentType = "image/tiff"
>> 'Response.ContentType = "application/pdf"
>>
>> Response.BinaryWrite objrec("attdata")

>
> Does that work? I use this:
>
> Set s = Server.CreateObject("ADODB.Stream")
> s.Mode = 3
> s.Type = 1
> s.Open
>
> // write the contents of the blob field to the stream
> s.Write objrec("attdata").Value
> s.Position = 0
>
> Response.ContentType = "image/tiff"
> Response.BinaryWrite s.Read()
>
> You can reuse the stream, just close it and open it again to clear it.
>
> As for multiple images in the same blob, that's a tough one... when you
> save a multi-page blob to file, can the file be opened in a normal image
> viewer? Maybe it's a single image that spans multiple logical pages? If
> not, and multiple image file structures are written to the field
> back-to-back, you'll have to separate the images by searching for the file
> header, signature, or some other unique feature with which the start of
> each image might be located. (It would be much easier to write each image
> to a different row, and associate those rows that go together, if you have
> any control over that end.)
>
> Given you're able to get valid images out of it, one approach to
> displaying multiple pages would be to generate an HTML document with
> multiple image tags, one for each page.
>
>
> -Mark
>
>
>
>> objrec.Close
>> Set objrec = Nothing
>> objCon.Close
>> Set objCon = Nothing
>> %>
>>
>> TIA!!
>>

>
>



 
Reply With Quote
 
CD
Guest
Posts: n/a
 
      07-10-2006
yes the above works. That is what i am guessing the application is placing
multi image in one row.

thanks for the reply

"Mark J. McGinty" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> "CD" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> An application is logging faxes sent in SQL2000 image column type. I
>> have found code on the net but what it is doing is prompting to save to
>> local which is fine for single page image. Not good for multiple page
>> faxes. I have not been able to locate an example to load in the browser
>> or how to handle multiple image in the one column.
>>
>> 1) Ideally it would be nice to display back in the browser since some may
>> be multiple images. I am not a programmer but any help is appreciated..
>>
>> <%
>> Dim strAttachID
>> strAttachID = Request.QueryString("AttachID")
>>
>> Dim objConn, objRS, strSQL
>>
>> adoconnectstr = "Driver={SQL
>> Server};database=faxmakerarchive;Server=XXXX;uid=X XXX;pwd=XXX;CommandTimeout
>> = 180"

>
> First, you should use the OLEDB provider instead of ODBC. (Use
> "Provider=SQLOLEDB;" in place of "Driver=...")
>
>
>> set objCon = server.CreateObject("ADODB.Connection")
>> set objRec = server.CreateObject("ADODB.Recordset")
>>
>> objCon.Open adoconnectstr
>> strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
>> "'"
>> objrec.Open strSQL, objCon
>>
>> Response.ContentType = "image/tiff"
>> 'Response.ContentType = "application/pdf"
>>
>> Response.BinaryWrite objrec("attdata")

>
> Does that work? I use this:
>
> Set s = Server.CreateObject("ADODB.Stream")
> s.Mode = 3
> s.Type = 1
> s.Open
>
> // write the contents of the blob field to the stream
> s.Write objrec("attdata").Value
> s.Position = 0
>
> Response.ContentType = "image/tiff"
> Response.BinaryWrite s.Read()
>
> You can reuse the stream, just close it and open it again to clear it.
>
> As for multiple images in the same blob, that's a tough one... when you
> save a multi-page blob to file, can the file be opened in a normal image
> viewer? Maybe it's a single image that spans multiple logical pages? If
> not, and multiple image file structures are written to the field
> back-to-back, you'll have to separate the images by searching for the file
> header, signature, or some other unique feature with which the start of
> each image might be located. (It would be much easier to write each image
> to a different row, and associate those rows that go together, if you have
> any control over that end.)
>
> Given you're able to get valid images out of it, one approach to
> displaying multiple pages would be to generate an HTML document with
> multiple image tags, one for each page.
>
>
> -Mark
>
>
>
>> objrec.Close
>> Set objrec = Nothing
>> objCon.Close
>> Set objCon = Nothing
>> %>
>>
>> TIA!!
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert TIFF-YC to TIFF-RGB Rubaiyat of Omar Bradley Digital Photography 11 06-27-2010 04:23 PM
BMP to TIFF or TIFF to BMP- any loss? Jenna Topping Digital Photography 5 01-23-2005 01:18 AM
Tool for converting 12-bit TIFF images to 16-bit TIFF-images? Peter Frank Digital Photography 11 12-13-2004 02:41 AM
jpeg to tiff and back to tiff ARosenblat Digital Photography 6 01-09-2004 08:53 PM
Image::Info::TIFF - multi-page tiff images page count ifiaz Perl Misc 1 11-19-2003 05:25 AM



Advertisments