SqlCommand cmd = new SqlCommand("ReadImage", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@imgId", SqlDbType.Int).Value = Convert.ToInt32(cmbImageID.SelectedValue.ToString()); SqlDataAdapter adp = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); try { if (con.State == ConnectionState.Closed) con.Open(); adp.Fill(dt); if (dt.Rows.Count > 0) { MemoryStream ms = new MemoryStream((byte[])dt.Rows[0]["ImageData"]); picImage.Image = Image.FromStream(ms); picImage.SizeMode = PictureBoxSizeMode.StretchImage; picImage.Refresh(); } } Table name = ImageData Column name= ImageData
CREATE PROCEDURE dbo.ReadImage (@imgId int) AS SELECT ImageData FROM ImageData WHERE ImageID=@imgId RETURN
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)