I am working C# desktop application with sqlite. Store Image path properly as
like C:\Users\USER\Pictures\pms_1484911839.45213251.jpg.
And I want to display the images in datagridview. My Code
private void loadTable(){
conn.Open();
SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter("SELECT * FROM products", conn);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
foodListView.AutoGenerateColumns = false;
foodListView.AllowUserToAddRows = false;
foodListView.RowHeadersVisible = false;
foodListView.DataSource = dt;
DataGridViewImageColumn imageColumn = new DataGridViewImageColumn();
Image img;
int i = 0;
imageColumn.HeaderText = "Image";
imageColumn.Name = "image";
foodListView.Columns.Insert(3, imageColumn);
foreach (DataRow dr in dt.Rows)
{
img = Image.FromFile(@dr["image"].ToString());
foodListView.Rows[i].Cells["image"].Value = img;
i++;
}
conn.Close();}
My Output is like
Where is my problem. Thank you.


@dr["image"].ToString()for any given record which isn't being displayed properly? What is the resultingimg? I'd also recommend declaring theimgvariable inside the loop so you're not potentially over-writing all previous images with each iteration of the loop. It's possible that only the last image is broken, but is also overwriting the rest of them.C:\Users\USER\Pictures\pms_1484911839.45213251.jpgwhich is exists. I also declareimginside the loop. No change happen.C:\Users\USER\Pictures\pms_1484911839.45213251.jpg