private void btnReadImage_Click(object sender, EventArgs e)
{
if (txtBrowse.Text != "")
{
String sql = "select UserPhoto, UserID, UserName,UserEmail, UserDescription from User_info where UserID='1'";
SqlConnection conn = new SqlConnection(@"Password=Sql2008;Persist Security Info=True;User ID=sa;Initial Catalog=anil;Data Source=SST-08\SQL2008");
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
SqlCommandBuilder cmd = new SqlCommandBuilder(da);
DataSet ds = new DataSet("User_info");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
da.Fill(ds, "User_info");
DataRow row = ds.Tables["User_info"].Rows[0];
byte[] rawdata = new byte[0];
rawdata = (byte[])row["UserPhoto"];
int len = new int();
len = rawdata.GetUpperBound(0);
FileStream fs = new FileStream(savedImageName, FileMode.OpenOrCreate, FileAccess.Write);
fs.Write(rawdata, 0, len);
fs.Close();
curImage = Image.FromFile(savedImageName);
pictureBox1.Image = curImage;
//conn.Close();
if (conn != null)
{
if (conn.State == ConnectionState.Open)
conn.Close();
conn.Dispose();
}
}
else
{
MessageBox.Show("First upload the image ");
}