blobtest.asp代码:
<%
set conn=server.createobject("adodb.connection")
dns="Provider=OraOLEDB.oracle.1;Data Source=sde;User ID=lhj;Password=lhj;Persist Security Info=False;"
conn.Open dns
Response.Expires=0
Response.Buffer = true
Response.Clear
dim rs
set rs=Server.CreateObject ("ADODB.Recordset")
sql="select blob_col from blob_demo where clbh = '1'"
rs.open sql,conn,1,1
if (not ((rs.BOF) and (rs.EOF))) then
Response.ContentType = "image/jpeg"
Response.BinaryWrite rs("blob_col")
else
Response.Write " No pic"
end if
rs.Close
conn.Close
set rs=nothing
set conn=nothing
set connGraph=nothing
%>
12 个解决方案
#1
听讲ado2.5以下不支持lob!
#2
那我怎么看我这个ADO的版本?//
#3
但像你这样读出lob是不行的,要做一个函数来转换
#4
rs.movenext
忘掉这个啦,当然是死循环!
忘掉这个啦,当然是死循环!
#5
我的一个例子
asppicture.asp
<html>
<head>
<title></title>
</head>
<body>
<p align="center"><img border="0" src="showpicture.asp" width="432" height="342"></p>
</body>
</html>
showpicture.asp
<%
'Dim sUserNO
'sUserNO = Request("userno")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
Set RS = Server.Createobject("ADODB.RecordSet")
sSQL = "select photo from dbadmin.s_user_photo_info where user_no='60000764'"
RS.Open sSQL,DBConn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite RS("photo").getChunk(7500000)
Set OraDynaset = Nothing
%>
asppicture.asp
<html>
<head>
<title></title>
</head>
<body>
<p align="center"><img border="0" src="showpicture.asp" width="432" height="342"></p>
</body>
</html>
showpicture.asp
<%
'Dim sUserNO
'sUserNO = Request("userno")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
Set RS = Server.Createobject("ADODB.RecordSet")
sSQL = "select photo from dbadmin.s_user_photo_info where user_no='60000764'"
RS.Open sSQL,DBConn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite RS("photo").getChunk(7500000)
Set OraDynaset = Nothing
%>
#6
我现在对这个问题也很矛盾:是这样的,如果我采用b/s结构方式,那么我应该写upload程序吧,但是这样upload是到web服务器的吧,
而我要存入数据库中的BLOB字段,应该先上传到数据库服务器吧,然后再用程序写入吧,那用B/S方式怎么实现
上船到数据库服务器呢??如果我采用C/S结构,我要把数据存入到远程(不是局域网)的数据库中,
这个试不是也很麻烦啊,大家帮我参考参考吧!
而我要存入数据库中的BLOB字段,应该先上传到数据库服务器吧,然后再用程序写入吧,那用B/S方式怎么实现
上船到数据库服务器呢??如果我采用C/S结构,我要把数据存入到远程(不是局域网)的数据库中,
这个试不是也很麻烦啊,大家帮我参考参考吧!
#7
不用先传到server吧哈。 asp不熟,这是我的vc的源程序:
CFile file;
if (!file.Open (filename ,CFile::modeRead))
return 2;
DWORD filesize=file.GetLength ();
char *m_pBuffer;
m_pBuffer=new char[filesize+1];
if (file.ReadHuge (m_pBuffer,filesize)!=filesize)
return 1;
char* pwritebase=m_pBuffer;
VARIANT varBlob;
SAFEARRAY* psa;
SAFEARRAYBOUND safebound[1];
if(pwritebase)
{
safebound[0].lLbound =0;
safebound[0].cElements =filesize;
psa=SafeArrayCreate(VT_UI1,1,safebound);
for (long i=0;i<(long)filesize;i++)
SafeArrayPutElement(psa,&i,pwritebase++);
varBlob.vt =VT_ARRAY | VT_UI1;
varBlob.parray =psa;
}
sqltext="insert into ";
sqltext+=(_bstr_t)tablename;
sqltext+=" (id,parentid,bedelete,data) values (?,?,0,?)";
m_commandptr.CreateInstance (__uuidof(Command));
m_commandptr->ActiveConnection =papp->m_pConnection ;
m_commandptr->CommandText =sqltext;
m_commandptr->CommandType =adCmdText;
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("tableitemid",adInteger,adParamInput,4,COleVariant((short)tableitemid)));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("parentid",adInteger,adParamInput,4,COleVariant((short)pitem->parentid )));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("data",/*adLongVarBinary*/adVarBinary,adParamInput,filesize+1,varBlob));
m_commandptr->Execute (NULL,NULL,adCmdUnknown);
delete []m_pBuffer;
CFile file;
if (!file.Open (filename ,CFile::modeRead))
return 2;
DWORD filesize=file.GetLength ();
char *m_pBuffer;
m_pBuffer=new char[filesize+1];
if (file.ReadHuge (m_pBuffer,filesize)!=filesize)
return 1;
char* pwritebase=m_pBuffer;
VARIANT varBlob;
SAFEARRAY* psa;
SAFEARRAYBOUND safebound[1];
if(pwritebase)
{
safebound[0].lLbound =0;
safebound[0].cElements =filesize;
psa=SafeArrayCreate(VT_UI1,1,safebound);
for (long i=0;i<(long)filesize;i++)
SafeArrayPutElement(psa,&i,pwritebase++);
varBlob.vt =VT_ARRAY | VT_UI1;
varBlob.parray =psa;
}
sqltext="insert into ";
sqltext+=(_bstr_t)tablename;
sqltext+=" (id,parentid,bedelete,data) values (?,?,0,?)";
m_commandptr.CreateInstance (__uuidof(Command));
m_commandptr->ActiveConnection =papp->m_pConnection ;
m_commandptr->CommandText =sqltext;
m_commandptr->CommandType =adCmdText;
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("tableitemid",adInteger,adParamInput,4,COleVariant((short)tableitemid)));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("parentid",adInteger,adParamInput,4,COleVariant((short)pitem->parentid )));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("data",/*adLongVarBinary*/adVarBinary,adParamInput,filesize+1,varBlob));
m_commandptr->Execute (NULL,NULL,adCmdUnknown);
delete []m_pBuffer;
#8
是这样的,一个把图片保存到数据库中的BLOB字段中,如果我采用b/s结构方式,那么我应该写upload程序吧(因为图片来自客户端的),但是这样upload是到web服务器的吧,用ASP等前台工具能把客户端的图片上传到数据库服务器并存入BLOB字段中吗??如果我采用C/S结构,我要把客户端的图片存入到远程(不是局域网)的数据库中,这个试不是也很麻烦啊,大家帮我参考参考吧!到底哪个方式为好啊
#9
没人肯帮忙吗??
#10
gz
#11
用form6i加图片很容易,asp我就不清楚了
#12
为什么不将 DBConn 放到Application对象中。每次输出一个图想创建一
个DBConn比较消耗时间。
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
另外,为了提高效率,你可以使用oracle 本身提供的一套访问数据库的
组件,0040(oracle object for ole).这套组件提供了对OCI的封装,应该
是所有组件中访问oracle数据库最快的。你可以看一下帮助。
个DBConn比较消耗时间。
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
另外,为了提高效率,你可以使用oracle 本身提供的一套访问数据库的
组件,0040(oracle object for ole).这套组件提供了对OCI的封装,应该
是所有组件中访问oracle数据库最快的。你可以看一下帮助。
#1
听讲ado2.5以下不支持lob!
#2
那我怎么看我这个ADO的版本?//
#3
但像你这样读出lob是不行的,要做一个函数来转换
#4
rs.movenext
忘掉这个啦,当然是死循环!
忘掉这个啦,当然是死循环!
#5
我的一个例子
asppicture.asp
<html>
<head>
<title></title>
</head>
<body>
<p align="center"><img border="0" src="showpicture.asp" width="432" height="342"></p>
</body>
</html>
showpicture.asp
<%
'Dim sUserNO
'sUserNO = Request("userno")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
Set RS = Server.Createobject("ADODB.RecordSet")
sSQL = "select photo from dbadmin.s_user_photo_info where user_no='60000764'"
RS.Open sSQL,DBConn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite RS("photo").getChunk(7500000)
Set OraDynaset = Nothing
%>
asppicture.asp
<html>
<head>
<title></title>
</head>
<body>
<p align="center"><img border="0" src="showpicture.asp" width="432" height="342"></p>
</body>
</html>
showpicture.asp
<%
'Dim sUserNO
'sUserNO = Request("userno")
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
Set RS = Server.Createobject("ADODB.RecordSet")
sSQL = "select photo from dbadmin.s_user_photo_info where user_no='60000764'"
RS.Open sSQL,DBConn,1,1
Response.ContentType = "image/*"
Response.BinaryWrite RS("photo").getChunk(7500000)
Set OraDynaset = Nothing
%>
#6
我现在对这个问题也很矛盾:是这样的,如果我采用b/s结构方式,那么我应该写upload程序吧,但是这样upload是到web服务器的吧,
而我要存入数据库中的BLOB字段,应该先上传到数据库服务器吧,然后再用程序写入吧,那用B/S方式怎么实现
上船到数据库服务器呢??如果我采用C/S结构,我要把数据存入到远程(不是局域网)的数据库中,
这个试不是也很麻烦啊,大家帮我参考参考吧!
而我要存入数据库中的BLOB字段,应该先上传到数据库服务器吧,然后再用程序写入吧,那用B/S方式怎么实现
上船到数据库服务器呢??如果我采用C/S结构,我要把数据存入到远程(不是局域网)的数据库中,
这个试不是也很麻烦啊,大家帮我参考参考吧!
#7
不用先传到server吧哈。 asp不熟,这是我的vc的源程序:
CFile file;
if (!file.Open (filename ,CFile::modeRead))
return 2;
DWORD filesize=file.GetLength ();
char *m_pBuffer;
m_pBuffer=new char[filesize+1];
if (file.ReadHuge (m_pBuffer,filesize)!=filesize)
return 1;
char* pwritebase=m_pBuffer;
VARIANT varBlob;
SAFEARRAY* psa;
SAFEARRAYBOUND safebound[1];
if(pwritebase)
{
safebound[0].lLbound =0;
safebound[0].cElements =filesize;
psa=SafeArrayCreate(VT_UI1,1,safebound);
for (long i=0;i<(long)filesize;i++)
SafeArrayPutElement(psa,&i,pwritebase++);
varBlob.vt =VT_ARRAY | VT_UI1;
varBlob.parray =psa;
}
sqltext="insert into ";
sqltext+=(_bstr_t)tablename;
sqltext+=" (id,parentid,bedelete,data) values (?,?,0,?)";
m_commandptr.CreateInstance (__uuidof(Command));
m_commandptr->ActiveConnection =papp->m_pConnection ;
m_commandptr->CommandText =sqltext;
m_commandptr->CommandType =adCmdText;
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("tableitemid",adInteger,adParamInput,4,COleVariant((short)tableitemid)));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("parentid",adInteger,adParamInput,4,COleVariant((short)pitem->parentid )));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("data",/*adLongVarBinary*/adVarBinary,adParamInput,filesize+1,varBlob));
m_commandptr->Execute (NULL,NULL,adCmdUnknown);
delete []m_pBuffer;
CFile file;
if (!file.Open (filename ,CFile::modeRead))
return 2;
DWORD filesize=file.GetLength ();
char *m_pBuffer;
m_pBuffer=new char[filesize+1];
if (file.ReadHuge (m_pBuffer,filesize)!=filesize)
return 1;
char* pwritebase=m_pBuffer;
VARIANT varBlob;
SAFEARRAY* psa;
SAFEARRAYBOUND safebound[1];
if(pwritebase)
{
safebound[0].lLbound =0;
safebound[0].cElements =filesize;
psa=SafeArrayCreate(VT_UI1,1,safebound);
for (long i=0;i<(long)filesize;i++)
SafeArrayPutElement(psa,&i,pwritebase++);
varBlob.vt =VT_ARRAY | VT_UI1;
varBlob.parray =psa;
}
sqltext="insert into ";
sqltext+=(_bstr_t)tablename;
sqltext+=" (id,parentid,bedelete,data) values (?,?,0,?)";
m_commandptr.CreateInstance (__uuidof(Command));
m_commandptr->ActiveConnection =papp->m_pConnection ;
m_commandptr->CommandText =sqltext;
m_commandptr->CommandType =adCmdText;
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("tableitemid",adInteger,adParamInput,4,COleVariant((short)tableitemid)));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("parentid",adInteger,adParamInput,4,COleVariant((short)pitem->parentid )));
m_commandptr->Parameters ->Append (m_commandptr->CreateParameter ("data",/*adLongVarBinary*/adVarBinary,adParamInput,filesize+1,varBlob));
m_commandptr->Execute (NULL,NULL,adCmdUnknown);
delete []m_pBuffer;
#8
是这样的,一个把图片保存到数据库中的BLOB字段中,如果我采用b/s结构方式,那么我应该写upload程序吧(因为图片来自客户端的),但是这样upload是到web服务器的吧,用ASP等前台工具能把客户端的图片上传到数据库服务器并存入BLOB字段中吗??如果我采用C/S结构,我要把客户端的图片存入到远程(不是局域网)的数据库中,这个试不是也很麻烦啊,大家帮我参考参考吧!到底哪个方式为好啊
#9
没人肯帮忙吗??
#10
gz
#11
用form6i加图片很容易,asp我就不清楚了
#12
为什么不将 DBConn 放到Application对象中。每次输出一个图想创建一
个DBConn比较消耗时间。
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
另外,为了提高效率,你可以使用oracle 本身提供的一套访问数据库的
组件,0040(oracle object for ole).这套组件提供了对OCI的封装,应该
是所有组件中访问oracle数据库最快的。你可以看一下帮助。
个DBConn比较消耗时间。
Set DBConn = Server.CreateObject("ADODB.Connection")
DBConn.Open "DSN=info;UID=dbadmin;PWD=1+1=2"
另外,为了提高效率,你可以使用oracle 本身提供的一套访问数据库的
组件,0040(oracle object for ole).这套组件提供了对OCI的封装,应该
是所有组件中访问oracle数据库最快的。你可以看一下帮助。