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
  1. Home
  2. Web Development
  3. ASP.NET
  4. How can I show text and HTML with image extracted from DB.

How can I show text and HTML with image extracted from DB.

Scheduled Pinned Locked Moved ASP.NET
questionhtmlasp-netdatabasecom
3 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.
  • R Offline
    R Offline
    Runar
    wrote on last edited by
    #1

    I have used article on how to save and show image from db: http://www.codeproject.com/aspnet/fileupload.asp?target=upload|image|database The form tag is set to

    I have tried to extract text and the image from db. I can see the image but not the text. I guess the form tag attribute enctype has something to do with this. Can anyone help me. Runar

    P 1 Reply Last reply
    0
    • R Runar

      I have used article on how to save and show image from db: http://www.codeproject.com/aspnet/fileupload.asp?target=upload|image|database The form tag is set to

      I have tried to extract text and the image from db. I can see the image but not the text. I guess the form tag attribute enctype has something to do with this. Can anyone help me. Runar

      P Offline
      P Offline
      Paul Watson
      wrote on last edited by
      #2

      In ASP.NET you really don't have to worry about multipart form data, unlike in ASP. Can you post some code please so that we can see how you are setting the form up and trying to access the data. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

      R 1 Reply Last reply
      0
      • P Paul Watson

        In ASP.NET you really don't have to worry about multipart form data, unlike in ASP. Can you post some code please so that we can see how you are setting the form up and trying to access the data. regards, Paul Watson Bluegrass South Africa Brian Welsch wrote: "blah blah blah, maybe a potato?" while translating my Afrikaans. Crikey! ain't life grand?

        R Offline
        R Offline
        Runar
        wrote on last edited by
        #3

        Form I use:

        I can now see that I can still view my image without multipart form, thanks. I'm not able to see my text fields / submit button with the image from DB. Here is the show ShowTheImage function: private void ShowTheImage(int FileID) { // Define SQL select statement string SQL = "SELECT FileSize, FileData, ContentType FROM tblFile WHERE FileID = " + FileID.ToString(); // Create Connection object SqlConnection dbConn = new SqlConnection("server=runar;database=ImgDb;user=sa"); // Create Command Object SqlCommand dbComm = new SqlCommand(SQL, dbConn); // Open Connection dbConn.Open(); // Execute command and receive DataReader SqlDataReader dbRead = dbComm.ExecuteReader(); // Read row dbRead.Read(); // Clear Response buffer Response.Clear(); // Set ContentType to the ContentType of our file Response.ContentType = (string)dbRead["ContentType"]; // Write data out of database into Output Stream Response.OutputStream.Write((byte[])dbRead["FileData"], 0, (int)dbRead["FileSize"]); // Close database connection dbConn.Close(); // End the page Response.End(); } Runar

        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