加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

[VB.NET]急求解答!怎样读取access中的图片

发布时间:2020-12-16 23:39:43 所属栏目:大数据 来源:网络整理
导读:急求解答!怎样读取access中的图片 大家好,我用vb.net连接access数据库,读取一个表的中的字段,这个字段是图片,但是一般图片应该是用路径表达,但是这个表里的图片却是“包”,我应该怎么读取,谢谢大家的帮助!!! ___________________________________

急求解答!怎样读取access中的图片
大家好,我用vb.net连接access数据库,读取一个表的中的字段,这个字段是图片,但是一般图片应该是用路径表达,但是这个表里的图片却是“包”,我应该怎么读取,谢谢大家的帮助!!!
__________________________________________________________________________
我的代码是这样的,从pro表中取字段tupian

Dim str As String
str = Request.QueryString( id )
Dim cnn As OleDbConnection
cnn = New OleDbConnection( Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Inetpub/wwwroot/home/data/Jaqua_Product.mdb )
Dim cmd As OleDbCommand
cmd = New OleDbCommand( select cpleibie,tupian from PRO where cpleibie= & str & )

cmd.Connection = cnn
cnn.Open()
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader()

Response.Write(













































) Do While dr.Read() Response.Write( ) Response.Write( )__________________________________________________________________________转换成二进制流来读,例如: private void ReadPicture(int ID) { string SQL = SELECT Picture,FileSize,ContentType FROM table WHERE ID = ID;//FileSize为图片大小,ContentType为图片格式 // Create Connection object OleDbConnection dbConn = new OleDbConnection(Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Inetpub/wwwroot/home/data/Jaqua_Product.mdb ); // Create Command Object OleDbCommand dbComm = new OleDbCommand(SQL,dbConn); // Open Connection dbConn.Open(); // Execute command and receive DataReader OleDbDataReader dbRead = dbComm.ExecuteReader(); dbRead.Read(); // Clear Response buffer Response.Clear(); // Set ContentType to the ContentType of our file // Response.ContentType = (string)dbRead[ ContentType ]; // Write data out of database into Output Stream Response.OutputStream.Write((byte[])dbRead[ Picture ],(int)dbRead[ FileSize ]); // Close database connection dbConn.Close(); // End the page Response.End(); } 把图片转换成二进制流.__________________________________________________________________________谢谢taoyuming(知识就是财富) 真诚的回答!__________________________________________________________________________
ID PASSWORD
+ dr.GetString(0) + + dr.GetString(1) +

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读