[VB.NET]急求解答!怎样读取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) +
原文链接:https://www.f2er.com/vb/263549.html

猜你在找的VB相关文章