我是asp+sql的站,本机测试时提示
“错误类型:
ADODB.Command (0x800A0E7D)
请求的操作需要 OLE DB 会话对象,而当前提供程序不支持此对象。
/news/NewsFun.asp, 第 12 行”看了很多帖子还是没找出来问题,不知道那个大哥能帮我看一下,我把conn.asp和newsfun.asp的代码贴出来:conn.asp:
<%
dim StrConn
dim Current_MainDir
dim conn
'StrConn="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=123;Initial Catalog=MCC_WebSite;Data Source=(127.0.0.1)"
StrConn="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=123;Initial Catalog=Endb_Mccarthy;Data Source=(127.0.0.1)"
set conn=Server.CreateObject("ADODB.connection")
Current_MainDir=server.mappath("/") & "\" '"F:\Work\Site_Business\"function CURRENT_MAIN_DIR()
CURRENT_MAIN_DIR=Current_MainDir
end functionfunction OpenConn()
on error resume next
conn.open StrConn
end functionfunction CloseConn()
on error resume next
conn.close
end function
'文本输入转换回行函数
function convert_br(sstring)
convert_br=sstring
on error resume next
convert_br=replace(replace(sstring,chr(13),"<br>")," "," ")
end function'文本输入转换回行函数
function convert_br_ob(sstring)
convert_br_ob=sstring
on error resume next
convert_br_ob=replace(sstring,"<br>",chr(13))
end function
function convert_br_space(sstring)
convert_br_space=sstring
on error resume next
convert_br_space=replace(sstring,"<br>"," ")
end functionfunction get_fileName(sstring,lenth)
get_fileName=""
on error resume next
get_fileName=right(sstring,lenth)
end function%>NewsFun.asp:
<!--#include file="../Include/Conn.asp"-->
<!--#include file="../Include/adovbs.inc"-->
<%
function getRecentNews(theNum)
dim num
dim rs
dim str
str=""
num=theNum
set objCmd=Server.CreateObject("Adodb.Command")
OpenConn
objCmd.ActiveConnection=conn
objCmd.CommandText="sp_GetFirmNews"
objCmd.CommandType=adCmdStoredProc
objCmd.Parameters.Append objCmd.CreateParameter("@Number",adInteger ,adParamInput ,,theNum)
set rs=objCmd.Execute if (rs.eof and rs.bof) then
getRecentNews=""
exit function
end if
num=rs("NUM")
if(num>theNum and theNum<>-1) then
num=theNum
end if
for i=1 to num
strtmp=rs("News_Title")
datetmp=rs("News_Created")
if len(strtmp)>20 then
strtmp=left(strtmp,20) & "…"
end if
'strtmp=strtmp & "<font color='#CCCCCC'>(" & FormatDateTime(datetmp,2) & ")</font>"
if(str="") then
str="<a class='linktxt1' target='_blank' href=NewsInfo.asp?NEWSID=" + rs("News_ID") + ">" & strtmp & "</a>"
else
str=str + lcase("<br>") + "<a class='linktxt1' target='_blank' href=NewsInfo.asp?NEWSID=" + rs("News_ID") + ">" & strtmp & "</a>"
end if
rs.movenext
next
getRecentNews=str
set rs=nothing
CloseConn
end function
%>
麻烦各位大虾了,非常感谢
“错误类型:
ADODB.Command (0x800A0E7D)
请求的操作需要 OLE DB 会话对象,而当前提供程序不支持此对象。
/news/NewsFun.asp, 第 12 行”看了很多帖子还是没找出来问题,不知道那个大哥能帮我看一下,我把conn.asp和newsfun.asp的代码贴出来:conn.asp:
<%
dim StrConn
dim Current_MainDir
dim conn
'StrConn="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=123;Initial Catalog=MCC_WebSite;Data Source=(127.0.0.1)"
StrConn="Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Password=123;Initial Catalog=Endb_Mccarthy;Data Source=(127.0.0.1)"
set conn=Server.CreateObject("ADODB.connection")
Current_MainDir=server.mappath("/") & "\" '"F:\Work\Site_Business\"function CURRENT_MAIN_DIR()
CURRENT_MAIN_DIR=Current_MainDir
end functionfunction OpenConn()
on error resume next
conn.open StrConn
end functionfunction CloseConn()
on error resume next
conn.close
end function
'文本输入转换回行函数
function convert_br(sstring)
convert_br=sstring
on error resume next
convert_br=replace(replace(sstring,chr(13),"<br>")," "," ")
end function'文本输入转换回行函数
function convert_br_ob(sstring)
convert_br_ob=sstring
on error resume next
convert_br_ob=replace(sstring,"<br>",chr(13))
end function
function convert_br_space(sstring)
convert_br_space=sstring
on error resume next
convert_br_space=replace(sstring,"<br>"," ")
end functionfunction get_fileName(sstring,lenth)
get_fileName=""
on error resume next
get_fileName=right(sstring,lenth)
end function%>NewsFun.asp:
<!--#include file="../Include/Conn.asp"-->
<!--#include file="../Include/adovbs.inc"-->
<%
function getRecentNews(theNum)
dim num
dim rs
dim str
str=""
num=theNum
set objCmd=Server.CreateObject("Adodb.Command")
OpenConn
objCmd.ActiveConnection=conn
objCmd.CommandText="sp_GetFirmNews"
objCmd.CommandType=adCmdStoredProc
objCmd.Parameters.Append objCmd.CreateParameter("@Number",adInteger ,adParamInput ,,theNum)
set rs=objCmd.Execute if (rs.eof and rs.bof) then
getRecentNews=""
exit function
end if
num=rs("NUM")
if(num>theNum and theNum<>-1) then
num=theNum
end if
for i=1 to num
strtmp=rs("News_Title")
datetmp=rs("News_Created")
if len(strtmp)>20 then
strtmp=left(strtmp,20) & "…"
end if
'strtmp=strtmp & "<font color='#CCCCCC'>(" & FormatDateTime(datetmp,2) & ")</font>"
if(str="") then
str="<a class='linktxt1' target='_blank' href=NewsInfo.asp?NEWSID=" + rs("News_ID") + ">" & strtmp & "</a>"
else
str=str + lcase("<br>") + "<a class='linktxt1' target='_blank' href=NewsInfo.asp?NEWSID=" + rs("News_ID") + ">" & strtmp & "</a>"
end if
rs.movenext
next
getRecentNews=str
set rs=nothing
CloseConn
end function
%>
麻烦各位大虾了,非常感谢
试试
将(127.0.0.1)的括号去掉即可连接如果还不行,进入sql server网络配置,将服务器端的网络协议中的icp/ip协议启用.