C#从数据库读取图片

2025-05-20 01:37:48
推荐回答(3个)
回答(1):

1、sql的单引号写错了,应该是"select image from student where number='"+label1.text+"'"
或者是"select top 1 image from student where number='"+label1.text+"'"
2、while(dr.Read())的while改成if

回答(2):

数据库中应存放的是图片的地址,图片存放于服务器端的文件夹中。
如果你考虑这个方案的话,可以贴一段代码给你。

回答(3):

改成dr.GetValue(0)