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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CD

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

    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.QuerySt ring("AttachID" )

    Dim objConn, objRS, strSQL

    adoconnectstr = "Driver={SQ L
    Server};databas e=faxmakerarchi ve;Server=XXXX; uid=XXXX;pwd=XX X;CommandTimeou t
    = 180"
    set objCon = server.CreateOb ject("ADODB.Con nection")
    set objRec = server.CreateOb ject("ADODB.Rec ordset")

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

    Response.Conten tType = "image/tiff"
    'Response.Conte ntType = "applicatio n/pdf"

    Response.Binary Write objrec("attdata ")

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

    TIA!!


  • Mark J. McGinty

    #2
    Re: Displaying image data from SQL...single/multipart tiff


    "CD" <mcdye1@hotmail .REMOVETHIS.com wrote in message
    news:OGDw5HgoGH A.4996@TK2MSFTN GP05.phx.gbl...
    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.QuerySt ring("AttachID" )
    >
    Dim objConn, objRS, strSQL
    >
    adoconnectstr = "Driver={SQ L
    Server};databas e=faxmakerarchi ve;Server=XXXX; uid=XXXX;pwd=XX X;CommandTimeou t
    = 180"
    First, you should use the OLEDB provider instead of ODBC. (Use
    "Provider=SQLOL EDB;" in place of "Driver=... ")

    set objCon = server.CreateOb ject("ADODB.Con nection")
    set objRec = server.CreateOb ject("ADODB.Rec ordset")
    >
    objCon.Open adoconnectstr
    strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
    "'"
    objrec.Open strSQL, objCon
    >
    Response.Conten tType = "image/tiff"
    'Response.Conte ntType = "applicatio n/pdf"
    >
    Response.Binary Write objrec("attdata ")
    Does that work? I use this:

    Set s = Server.CreateOb ject("ADODB.Str eam")
    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.Conten tType = "image/tiff"
    Response.Binary Write 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!!
    >

    Comment

    • CD

      #3
      Re: Displaying image data from SQL...single/multipart tiff

      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" <mmcginty@spamf romyou.comwrote in message
      news:em3y0p0oGH A.4192@TK2MSFTN GP03.phx.gbl...
      >
      "CD" <mcdye1@hotmail .REMOVETHIS.com wrote in message
      news:OGDw5HgoGH A.4996@TK2MSFTN GP05.phx.gbl...
      >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.QuerySt ring("AttachID" )
      >>
      > Dim objConn, objRS, strSQL
      >>
      >adoconnectst r = "Driver={SQ L
      >Server};databa se=faxmakerarch ive;Server=XXXX ;uid=XXXX;pwd=X XX;CommandTimeo ut
      >= 180"
      >
      First, you should use the OLEDB provider instead of ODBC. (Use
      "Provider=SQLOL EDB;" in place of "Driver=... ")
      >
      >
      >set objCon = server.CreateOb ject("ADODB.Con nection")
      >set objRec = server.CreateOb ject("ADODB.Rec ordset")
      >>
      >objCon.Open adoconnectstr
      >strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
      >"'"
      > objrec.Open strSQL, objCon
      >>
      > Response.Conten tType = "image/tiff"
      > 'Response.Conte ntType = "applicatio n/pdf"
      >>
      > Response.Binary Write objrec("attdata ")
      >
      Does that work? I use this:
      >
      Set s = Server.CreateOb ject("ADODB.Str eam")
      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.Conten tType = "image/tiff"
      Response.Binary Write 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!!
      >>
      >
      >

      Comment

      • CD

        #4
        Re: Displaying image data from SQL...single/multipart tiff

        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" <mmcginty@spamf romyou.comwrote in message
        news:em3y0p0oGH A.4192@TK2MSFTN GP03.phx.gbl...
        >
        "CD" <mcdye1@hotmail .REMOVETHIS.com wrote in message
        news:OGDw5HgoGH A.4996@TK2MSFTN GP05.phx.gbl...
        >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.QuerySt ring("AttachID" )
        >>
        > Dim objConn, objRS, strSQL
        >>
        >adoconnectst r = "Driver={SQ L
        >Server};databa se=faxmakerarch ive;Server=XXXX ;uid=XXXX;pwd=X XX;CommandTimeo ut
        >= 180"
        >
        First, you should use the OLEDB provider instead of ODBC. (Use
        "Provider=SQLOL EDB;" in place of "Driver=... ")
        >
        >
        >set objCon = server.CreateOb ject("ADODB.Con nection")
        >set objRec = server.CreateOb ject("ADODB.Rec ordset")
        >>
        >objCon.Open adoconnectstr
        >strSQL = "SELECT attdata FROM fm_faxout_att WHERE ID ='" & strAttachID &
        >"'"
        > objrec.Open strSQL, objCon
        >>
        > Response.Conten tType = "image/tiff"
        > 'Response.Conte ntType = "applicatio n/pdf"
        >>
        > Response.Binary Write objrec("attdata ")
        >
        Does that work? I use this:
        >
        Set s = Server.CreateOb ject("ADODB.Str eam")
        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.Conten tType = "image/tiff"
        Response.Binary Write 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!!
        >>
        >
        >

        Comment

        Working...