Image's path
-
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
-
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
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
-
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
-
:confused:
only two letters away from being an asset