日期:2014-05-18 浏览次数:20763 次
string tmp=treeView1.SelectedNode.Text; SqlDataReader read = Connect.Getdataread("select * from Employees"); while (read.Read()) { if (tmp == read.GetString(1).ToString()+' ' + read.GetString(2).ToString()) { textBox1.Text = read.GetInt32(0).ToString(); textBox2.Text = read.GetString(1).ToString() + read.GetString(2).ToString(); textBox3.Text = read.GetString(3).ToString(); textBox4.Text = read.GetString(7).ToString(); MemoryStream ms=new MemoryStream(read.GetBytes(14)); Image img = Image.FromStream(ms); pictureBox1.Image = img; } }
String sql = "select * from picture where [id]=2"; string str = "server=DA5A491B3F7544B;database=study;uid=sa;pwd=liyi123"; SqlConnection con = new SqlConnection(str); con.Open(); SqlCommand cmd=new SqlCommand(sql,con); SqlDataReader sdr = cmd.ExecuteReader(); if(sdr.HasRows) { sdr.Read(); byte[] bytes = (byte[]) sdr["pic"]; MemoryStream ms =new MemoryStream(bytes); Image image = Image.FromStream(ms); pictureBox1.Image = image; } sdr.Close(); con.Close();