永发信息网

asp 打开有BLOB字段,提示数据类型不被支持。

答案:2  悬赏:60  手机版
解决时间 2021-02-23 16:48
  • 提问者网友:战魂
  • 2021-02-23 03:12
<%dim cnn
set cnn=server.CreateObject("ADODB.Connection")
constr="Provider=MSDAORA;Data Source=server;User ID=anything; Password=67375272"
cnn.open constr
if err then
err.clear
echoerr("打开数据库失败!
可能因配置错误或驱动程序版本太低!")
response.end
end if
%>
<%

dim search,rs,j
search="select * from arc_orgfile "
set rs=Server.CreateObject("ADODB.Recordset")
rs.Open search,cnn,1,3
if rs.bof or rs.eof then
response.write "错误:找不到该文件"
response.end
end if

'设置文件的大小及MIME类型
Function SetForDisplay(field, contentType)
contentType = LCase(trim(contentType))
nFieldSize = field.ActualSize
bytes = field.GetChunk(nFieldSize)
Session("Bytes") = bytes
Session("Type") = contentType
End Function

SetForDisplay RS("File"),rs("FileType")
'Response.AddHeader "Content-Disposition", "attachment; filename=" & rs("FileName")
response.contentType = Session("Type")
response.BinaryWrite Session("Bytes")
Session("Type") = ""
Session("Bytes") = ""

%>
我用的是oracle数据库,其中一表中有一字段是blob类型,其里面存放的是二进制形式的文件内容
运行之后显示:
Microsoft OLE DB Provider for Oracle 错误 '80004005'

数据类型不被支持。

/windy/windywindy.asp,行 18

第18行是:rs.Open search,cnn,1,3
最佳答案
  • 五星知识达人网友:醉吻情书
  • 2021-02-23 04:09
呵呵,还没用过orale数据库,希望下次能帮到你,帮顶.
全部回答
  • 1楼网友:洎扰庸人
  • 2021-02-23 05:45
hbm.xml <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-mapping public "-//hibernate/hibernate mapping dtd 3.0//en" " http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping>     <class name="hibernate.blobtest" table="blobtest" catalog="hbtplis">     <id name="id" type="java.lang.long">     <column name="id" />     <generator class="native" />     </id>     <property name="images" type="java.sql.blob">     <column name="images" />     </property>     <property name="name" type="java.lang.string">     <column name="name" />     </property>     </class> </hibernate-mapping> pojo: package hibernate; import java.sql.blob; public class blobtest implements java.io.serializable { private long id; private blob images; private string name; public blobtest() { } public blobtest(blob images, string name) {    this.images = images;    this.name = name; } public long getid() {    return this.id; } public void setid(long id) {    this.id = id; } public blob getimages() {    return this.images; } public void setimages(blob images) {    this.images = images; } public string getname() {    return this.name; } public void setname(string name) {    this.name = name; } } dao: package hibernate; import java.io.fileoutputstream; import java.io.inputstream; import java.sql.blob; import org.hibernate.hibernate; import org.hibernate.lockmode; import org.hibernate.transaction; public class blobtestdao extends basehibernatedao { public void save(blobtest blobtest) throws exception {    try {         //对于oracle这样的数据库不能以第一种方式那样,必须向下面这样操作     transaction tran=getsession().begintransaction();     blobtest.setimages(hibernate.createblob(new byte[1]));     getsession().save(blobtest);     getsession().flush();     getsession().refresh(blobtest,lockmode.upgrade);     blob blob=blobtest.getimages();     inputstream is=blob.getbinarystream();     fileoutputstream fos=new fileoutputstream("d:\\pic\\linux4.jpg");     byte[] buf=new byte[102400];     int len;     while((len=is.read(buf))!=-1){     fos.write(buf,0,len);     }     fos.close();     is.close();     getsession().save(blobtest);     tran.commit();    } catch (runtimeexception re) {     throw re;    } } }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯