Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQLDataReader for image type

SQLDataReader for image type

Scheduled Pinned Locked Moved Database
databasesql-serversysadmintutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mysorian
    wrote on last edited by
    #1

    SQLDataReader should read from the stream. When the incoming stream has image type info [for example, images from a Sql server], the reader can only read a single image. I wonder what is happening. Apparently, a mixed stream is hard to read: -------------------------------- while drPic.read Response.ContentType = "image/bmp" Response.BinaryWrite(drPic.Item("pic")) end while -------------------------------- It has 20 pictures, but I get only one. If I add any other fields, they get skipped.

    L 1 Reply Last reply
    0
    • M mysorian

      SQLDataReader should read from the stream. When the incoming stream has image type info [for example, images from a Sql server], the reader can only read a single image. I wonder what is happening. Apparently, a mixed stream is hard to read: -------------------------------- while drPic.read Response.ContentType = "image/bmp" Response.BinaryWrite(drPic.Item("pic")) end while -------------------------------- It has 20 pictures, but I get only one. If I add any other fields, they get skipped.

      L Offline
      L Offline
      Luis Alonso Ramos
      wrote on last edited by
      #2

      I've never used image types in SQL Server, but, are all the images in the same field? Or do you get all the images, each from one field, and try to output all of them with Reponse.BinaryWrite? If you are trying to output all of them to the browser, then probably you should generate an HTML file that contains all the images. I don't the browser supports displaying multiple images by themselves at once (ie. several URLs for JPG files, one after another) I've never worked with it, but just an idea. -- LuisR


      Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

      M 1 Reply Last reply
      0
      • L Luis Alonso Ramos

        I've never used image types in SQL Server, but, are all the images in the same field? Or do you get all the images, each from one field, and try to output all of them with Reponse.BinaryWrite? If you are trying to output all of them to the browser, then probably you should generate an HTML file that contains all the images. I don't the browser supports displaying multiple images by themselves at once (ie. several URLs for JPG files, one after another) I've never worked with it, but just an idea. -- LuisR


        Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

        M Offline
        M Offline
        mysorian
        wrote on last edited by
        #3

        Luis: Let's say you are writing out the column that contains 8 rows of, say text (string type), the Execute Reader will get you 8 rows of data for that column assuming you arranged it that way. On the other hand if the 8 rows had data of type image, the Response.Binary write seems to write just the first row and nothing else. I am a bit surprised, but trying to find why this happens?. Also if you wanted both text and image to be read out, it looks like there is something that prevents writing text and image, you get image only. I have been trying several tricks, but so far not much of a success. If I succeed I will let you know. mysorian:~

        L 1 Reply Last reply
        0
        • M mysorian

          Luis: Let's say you are writing out the column that contains 8 rows of, say text (string type), the Execute Reader will get you 8 rows of data for that column assuming you arranged it that way. On the other hand if the 8 rows had data of type image, the Response.Binary write seems to write just the first row and nothing else. I am a bit surprised, but trying to find why this happens?. Also if you wanted both text and image to be read out, it looks like there is something that prevents writing text and image, you get image only. I have been trying several tricks, but so far not much of a success. If I succeed I will let you know. mysorian:~

          L Offline
          L Offline
          Luis Alonso Ramos
          wrote on last edited by
          #4

          In your code, you're setting the response type to "image/bmp" and that's why if you output text into the response, you can't see it. When the response type is "image/bmp", the browser treats everything it gets as a single BMP file. If you send some text (or more images) they're treated as part of the first BMP file. Because of the format of BMP files, you can add data at the end of the file and the image won't be corrupted. So, no matter what you output to the browser, you only see the first image you send. If you want to see multiple files, you would have to build on the fly an HTML file full of IMG tags. -- LuisR


          Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

          M 1 Reply Last reply
          0
          • L Luis Alonso Ramos

            In your code, you're setting the response type to "image/bmp" and that's why if you output text into the response, you can't see it. When the response type is "image/bmp", the browser treats everything it gets as a single BMP file. If you send some text (or more images) they're treated as part of the first BMP file. Because of the format of BMP files, you can add data at the end of the file and the image won't be corrupted. So, no matter what you output to the browser, you only see the first image you send. If you want to see multiple files, you would have to build on the fly an HTML file full of IMG tags. -- LuisR


            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

            M Offline
            M Offline
            mysorian
            wrote on last edited by
            #5

            Thanks. I did try that, may be something else was not correct. Back to the board I think. :eek: mysorian

            L 1 Reply Last reply
            0
            • M mysorian

              Thanks. I did try that, may be something else was not correct. Back to the board I think. :eek: mysorian

              L Offline
              L Offline
              Luis Alonso Ramos
              wrote on last edited by
              #6

              You're welcome. We're here to help! Good luck! -- LuisR


              Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups