Who can help me?? Microsoft Visual Studio 2008 Window Form Application C#

I'm want store some data and picture in access database and display the data and picture in datagridview. when the user double click the record in datagridview. it will display data and picture into above textbox for update purpose.

Recommended Answers

All 6 Replies

anyone can help me???

check this link.... and this link.... I also came across an old thread here

To place your picture in textbox check this thread

Can u send me full example. Cos i'm still not very clear to know

I'm successful add image to access database. Now I'm want retrieve image.
For example, I'm want to double click record in datagridview and then display image into picturebox.

Insert the following code in the Click event procedure of Button2 (Database to PictureBox). This code retrieves the rows from the BLOBTest table in the database into a DataSet, copies the most recently added image into a Byte array and then into a MemoryStream object, and then loads the MemoryStream into the Image property of the PictureBox control.

try
{
	SqlConnection cn = new SqlConnection(strCn);
	cn.Open();

	//Retrieve BLOB from database into DataSet.
	SqlCommand cmd = new SqlCommand("SELECT BLOBID, BLOBData FROM BLOBTest ORDER BY BLOBID", cn);	
	SqlDataAdapter da = new SqlDataAdapter(cmd);
	DataSet ds = new DataSet();
	da.Fill(ds, "BLOBTest");
	int c = ds.Tables["BLOBTest"].Rows.Count;

	if(c>0)
	{   //BLOB is read into Byte array, then used to construct MemoryStream,
		//then passed to PictureBox.
		Byte[] byteBLOBData =  new Byte[0];
		byteBLOBData = (Byte[])(ds.Tables["BLOBTest"].Rows[c - 1]["BLOBData"]);
		MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
		pictureBox1.Image= Image.FromStream(stmBLOBData);
	} 
	cn.Close();
}
catch(Exception ex)
{MessageBox.Show(ex.Message);}

Also check "retrieve image from access db to picturebox" an old thread in this community

Insert the following code in the Click event procedure of Button2 (Database to PictureBox). This code retrieves the rows from the BLOBTest table in the database into a DataSet, copies the most recently added image into a Byte array and then into a MemoryStream object, and then loads the MemoryStream into the Image property of the PictureBox control.

try
{
	SqlConnection cn = new SqlConnection(strCn);
	cn.Open();

	//Retrieve BLOB from database into DataSet.
	SqlCommand cmd = new SqlCommand("SELECT BLOBID, BLOBData FROM BLOBTest ORDER BY BLOBID", cn);	
	SqlDataAdapter da = new SqlDataAdapter(cmd);
	DataSet ds = new DataSet();
	da.Fill(ds, "BLOBTest");
	int c = ds.Tables["BLOBTest"].Rows.Count;

	if(c>0)
	{   //BLOB is read into Byte array, then used to construct MemoryStream,
		//then passed to PictureBox.
		Byte[] byteBLOBData =  new Byte[0];
		byteBLOBData = (Byte[])(ds.Tables["BLOBTest"].Rows[c - 1]["BLOBData"]);
		MemoryStream stmBLOBData = new MemoryStream(byteBLOBData);
		pictureBox1.Image= Image.FromStream(stmBLOBData);
	} 
	cn.Close();
}
catch(Exception ex)
{MessageBox.Show(ex.Message);}

Also check "retrieve image from access db to picturebox" an old thread in this community

thanks.I'm slove my problem already.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.