i m doing project in c#.net iput path of image into database(sqlserver),and fetch those image from database into gridview...
i use to write this code as.
SqlDataReader rdr = dal.ExecuteReader("select image from studentreg where eventname like '%" + lblheading.Text + "%'", ref message);
if (rdr.HasRows)
{
string imgpath;
rdr.Read();
DataGridViewRow dgvr = new DataGridViewRow();
imgpath = rdr.GetString(0);
Image newimg = Image.FromFile(imgpath);
DataGridViewImageColumn ic = new DataGridViewImageColumn();
ic.Image = newimg;
ic.Name = "image";
ic.HeaderText = "image";
dgvr.Cells[0].Value = newimg;
dgv.Rows.Add(dgvr);
dgv.Columns.Insert(0, ic);
}
if (dt != null && dt.Rows.Count > 0)
{
dgv.DataSource = null;
dgv.DataSource = dt;
Point p = new Point(Screen.PrimaryScreen.WorkingArea.Width / 2 - this.Width / 5, Screen.PrimaryScreen.WorkingArea.Height / 2 - this.Height / 4);
this.Location = p;
}
else
{
dgv.DataSource = null;
MessageBox.Show("No any Registration...!");
}