CodeKuga88 CodeKuga88 - 22 days ago 5
C# Question

Retrieving images from ssms Database using relative path and showing image in picture box in C# visual studio 2012?

I am making a win-forms program in C# visual studio. I have the relative paths for all the images stored in the database. What I am trying to do is make it so that when an item is selected from the combobox, a stored proc is executed it returns the datatable and places everything in the relevant textbox.

However, one column is the relative path for the .JPEG image. I need to get the relative path and somehow convert it so that the program gets the actual image and display it in the PictureBox.

private void cmbEOselect_SelectionChangeCommitted(object sender, EventArgs e)
{
DataTable SO = new DataTable();

txtbEOname.Text = (String)SO.Rows[cmbEOselect.SelectedIndex]["Name"];

String folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
+ @"\........\.jpeg pBoxOils.Load(folder);
txtbEObottn = (String)SO.Rows[cmbEOselect.SelectedIndex]["BottanicalName"];
txtbEOext.Text = (String)SO.Rows[cmbEOselect.SelectedIndex]["Extraction"];

}

Answer
txtbEOname.Text = (String)PEO.Rows[cmbEOselect.SelectedIndex]["Name"];
            String folder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) +   @"" + PEO.Rows[cmbEOselect.SelectedIndex]["IMAGE"];
            pBoxOils.Load(folder);
Comments