Bitmap ByteArrayToImage(byte[] b) { MemoryStream ms = new MemoryStream(); byte[] pData = b; ms.Write(pData, 0, Convert.ToInt32(pData.Length)); Bitmap bm = new Bitmap(ms, false);//Parameter is not valid. ms.Dispose(); return bm; } int ctr = 0; //int len = 0; private void button1_Click(object sender, EventArgs e) { da = new SqlDataAdapter("select * from Slambook_Data where serial_no=" + textBox1.Text + "", con); ds = new DataSet(); da.Fill(ds, "Slambook_Data"); ctr = ds.Tables["Slambook_Data"].Rows.Count; if (ds.Tables["Slambook_Data"].Rows.Count > 0) { if (ds.Tables["Slambook_Data"].Rows[0]["photo"] != DBNull.Value) { label1.Text = ds.Tables["Slambook_Data"].Rows[0]["name"].ToString(); pictureBox1.Image = ByteArrayToImage((Byte[])ds.Tables["Slambook_Data"].Rows[0]["photo"]); } } }
Convert.ToInt32(pData.Length))
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)