数据库是SQL2005,如何在VS2008水晶报表中显示Image字段
1个回答
展开全部
privatevoid button1_Click(object sender, EventArgs e)
{
BindPicture();
}
privatevoid BindPicture()
{
string sql = ReportForm.Properties.Settings.Default.ZXHConnectionString;
SqlConnection conn =new SqlConnection(sql);
string testsql ="select Picture from ProductTab where ProID = "+ comboBox1.Text.Trim().ToString() ;
SqlCommand cmd =new SqlCommand(testsql, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
MemoryStream ms =new MemoryStream((byte[])reader["Picture"]);
Image image = Image.FromStream(ms, true);
reader.Close();
conn.Close();
pictureBox1.Image = image;
}
{
BindPicture();
}
privatevoid BindPicture()
{
string sql = ReportForm.Properties.Settings.Default.ZXHConnectionString;
SqlConnection conn =new SqlConnection(sql);
string testsql ="select Picture from ProductTab where ProID = "+ comboBox1.Text.Trim().ToString() ;
SqlCommand cmd =new SqlCommand(testsql, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
reader.Read();
MemoryStream ms =new MemoryStream((byte[])reader["Picture"]);
Image image = Image.FromStream(ms, true);
reader.Close();
conn.Close();
pictureBox1.Image = image;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询