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. Web Development
  3. ASP.NET
  4. how to display pictures in image tool

how to display pictures in image tool

Scheduled Pinned Locked Moved ASP.NET
databasesql-serversysadmintutorial
5 Posts 2 Posters 1 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.
  • N Offline
    N Offline
    n_gchaitra
    wrote on last edited by
    #1

    Hi, how to bind image present in sql server to image tool.

    Chaitra N

    A 1 Reply Last reply
    0
    • N n_gchaitra

      Hi, how to bind image present in sql server to image tool.

      Chaitra N

      A Offline
      A Offline
      Ather Ali Shaikh
      wrote on last edited by
      #2

      take the binary of the image from database. make a stream. write that stream into a blank Web User Control. as Response.Write and then assign it to your image control as ImageURL="myPic.ascx" I hope you understand what I mean. Regards, Ather Ali

      Ather Ali Shaikh Project Manager Micromedia Computer shaikhather@gmail.com

      N 1 Reply Last reply
      0
      • A Ather Ali Shaikh

        take the binary of the image from database. make a stream. write that stream into a blank Web User Control. as Response.Write and then assign it to your image control as ImageURL="myPic.ascx" I hope you understand what I mean. Regards, Ather Ali

        Ather Ali Shaikh Project Manager Micromedia Computer shaikhather@gmail.com

        N Offline
        N Offline
        n_gchaitra
        wrote on last edited by
        #3

        Hi Ather Ali, I understood what you are telling but not getting how to do it. I have the following code. Picture is getting displayed. It is ok. But not in the image control. suppose if I have a imagecontrol Image1 how can i do this? Dim ImageID As Integer = Convert.ToInt32(Request.QueryString("ImageID")) 'Connect to the database and bring back the image contents & MIME type for the specified picture Const SQL As String = "SELECT [MIMEType], [Image] FROM [Pictures] WHERE [ImageID] = @ImageID" Dim myCommand As New SqlCommand(SQL, myconnection) myCommand.Parameters.AddWithValue("@ImageID", 1) myconnection.Open() Dim myReader As SqlDataReader = myCommand.ExecuteReader If myReader.Read Then Response.ContentType = myReader("MIMEType").ToString() Response.BinaryWrite(myReader("Image")) End If myReader.Close() myconnection.Close()

        Chaitra N

        A 1 Reply Last reply
        0
        • N n_gchaitra

          Hi Ather Ali, I understood what you are telling but not getting how to do it. I have the following code. Picture is getting displayed. It is ok. But not in the image control. suppose if I have a imagecontrol Image1 how can i do this? Dim ImageID As Integer = Convert.ToInt32(Request.QueryString("ImageID")) 'Connect to the database and bring back the image contents & MIME type for the specified picture Const SQL As String = "SELECT [MIMEType], [Image] FROM [Pictures] WHERE [ImageID] = @ImageID" Dim myCommand As New SqlCommand(SQL, myconnection) myCommand.Parameters.AddWithValue("@ImageID", 1) myconnection.Open() Dim myReader As SqlDataReader = myCommand.ExecuteReader If myReader.Read Then Response.ContentType = myReader("MIMEType").ToString() Response.BinaryWrite(myReader("Image")) End If myReader.Close() myconnection.Close()

          Chaitra N

          A Offline
          A Offline
          Ather Ali Shaikh
          wrote on last edited by
          #4

          This Code is OK. Put this code in a ASCX control and take the ImageID from QueryString. and there should not be any thing in HTML side. Whereever you want to put this image on any page. place a image control on that page and as source refere to this control like I hope it will sove your problem. I have already did it in my one of the application. Regards, Ather Ali

          Ather Ali Shaikh Project Manager Micromedia Computer shaikhather@gmail.com

          N 1 Reply Last reply
          0
          • A Ather Ali Shaikh

            This Code is OK. Put this code in a ASCX control and take the ImageID from QueryString. and there should not be any thing in HTML side. Whereever you want to put this image on any page. place a image control on that page and as source refere to this control like I hope it will sove your problem. I have already did it in my one of the application. Regards, Ather Ali

            Ather Ali Shaikh Project Manager Micromedia Computer shaikhather@gmail.com

            N Offline
            N Offline
            n_gchaitra
            wrote on last edited by
            #5

            Thank you. It worked.

            Chaitra N

            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