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. General Programming
  3. C#
  4. Image's path

Image's path

Scheduled Pinned Locked Moved C#
databasehelptutorialquestion
4 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.
  • N Offline
    N Offline
    Nine_
    wrote on last edited by
    #1

    Hi all, I'm working on a project using Visual Studio2005. I have saved an image path to the database. The code is something like this: ----------------------------------------------- . . . OpenFileDialog openImgFile = new OpenFileDialog(); if (openImgFile.ShowDialog() == DialogResult.OK) { imgPath= openImgFile.FileName; pictureBox1.Image = Image.FromFile(imgPath); } cmdStr = "insert into img_tbl(imgID,imgPath)values('01',@path)"; cmd = new SqlCommand(cmdStr, cnn); SqlParameter path = new SqlParameter("@path", SqlDbType.NVarChar, 225); path.Value = imgPath; cmd.Parameters.Add(path); cmd.ExecuteNonQuery(); . . . What I got from that is an image path storing in the database, something like this: C:\Documents and Settings\Desktop\foto_311.jpg But the problem is when I use this path to get an image to display on a form, it dosen't work! If I change a little like this: C:\\Documents and Settings\\Desktop\\foto_311.jpg then it works. So can anyone tell me how to change it before being saved? Thankz

    N 1 Reply Last reply
    0
    • N Nine_

      Hi all, I'm working on a project using Visual Studio2005. I have saved an image path to the database. The code is something like this: ----------------------------------------------- . . . OpenFileDialog openImgFile = new OpenFileDialog(); if (openImgFile.ShowDialog() == DialogResult.OK) { imgPath= openImgFile.FileName; pictureBox1.Image = Image.FromFile(imgPath); } cmdStr = "insert into img_tbl(imgID,imgPath)values('01',@path)"; cmd = new SqlCommand(cmdStr, cnn); SqlParameter path = new SqlParameter("@path", SqlDbType.NVarChar, 225); path.Value = imgPath; cmd.Parameters.Add(path); cmd.ExecuteNonQuery(); . . . What I got from that is an image path storing in the database, something like this: C:\Documents and Settings\Desktop\foto_311.jpg But the problem is when I use this path to get an image to display on a form, it dosen't work! If I change a little like this: C:\\Documents and Settings\\Desktop\\foto_311.jpg then it works. So can anyone tell me how to change it before being saved? Thankz

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      Where is your code to retrieve the image path from the database and display it? http://www.codeproject.com/cs/database/albumviewer.asp[^]


      only two letters away from being an asset

      N 1 Reply Last reply
      0
      • N Not Active

        Where is your code to retrieve the image path from the database and display it? http://www.codeproject.com/cs/database/albumviewer.asp[^]


        only two letters away from being an asset

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

        The retrieve code not included there

        N 1 Reply Last reply
        0
        • N Nine_

          The retrieve code not included there

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          :confused:


          only two letters away from being an asset

          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