OpenFileDialog dlg = new OpenFileDialog(); DialogResult dlgRes = dlg.ShowDialog(); if (dlgRes != DialogResult.Cancel) { //Set image in picture box pictureBox1.ImageLocation = dlg.FileName; //Provide file path in txtImagePath text box. txtimagepath.Text = dlg.FileName; } MemoryStream stream = new MemoryStream(); pictureBox1.Image.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg); byte[] imageData = stream.ToArray(); //and below code use for fatch image : SqlDataAdapter dataAdapter = new SqlDataAdapter(new SqlCommand("select imgdata from Joiningform where regno='" + regno + "'",con)); DataSet dataSet = new DataSet(); dataAdapter.Fill(dataSet); if (dataSet.Tables[0].Rows.Count == 1) { Byte[] data = new Byte[0]; data = (Byte[])(dataSet.Tables[0].Rows[0]["imgdata"]); MemoryStream mem = new MemoryStream(data); pictureBox1.Image = Image.FromStream(mem); }
con.Open(); SqlDataAdapter dataAdapter = new SqlDataAdapter(new SqlCommand("select imgdata from Joiningform where regno='" + regno + "'",con));
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)