Situation: I've been trying to get picture from database and put it on picturebox. Database was BLOB type. I tried the methods given to me (How to retrieve image from database and paste to picturebox?), and sadly nothing worked. So, instead of BLOB, I decided to use string and get the full path of the image.
Problem: The slashes are gone. Database example
Code:
private void pbox1_Click(object sender, EventArgs e)
{
OpenFileDialog rest = new OpenFileDialog();
rest.Filter = "images| *.JPG; *.PNG; *.GIF";
if (rest.ShowDialog() == DialogResult.OK)
{
pbox1.Image = Image.FromFile(rest.FileName);
filename = Path.GetFullPath(rest.FileName);
}
}
I insert it into database ("filename" is a global variable):
MySqlCommand comm = new MySqlCommand("INSERT INTO casestudyprofile(lastname, firstname, birthdate, status, caseage, program, dateJoined, picture, address) VALUES('" + lname + "', '" + fname + "', '" + dtbirth.Value.Date.ToString("yyyyMMdd") + "','" + status + "','" + age + "','" + program + "','" + dtjoin.Value.Date.ToString("yyyy/MM/dd") + "', '" + filename + "', '" + address + "')", conn);
Then I call it like this:
pbox2.ImageLocation = dt.Rows[0]["picture"].ToString();
I found out it won't work because the full path stored in database have their slashes removed. I manually put them in the database and it worked. But, how in code? Any help is greatly appreciated.