数据库连接
想了很久,不知道问题在哪,请高手指正一个,先谢了!
<%
' 创建数据库连接
Function GetConn(connstr)
Set conn = Server.CreateObject( "ADODB.Connection ")
conn.Open connstr
Set GetConn = conn
End Function
' 创建access数据库连接
Function GetMDBConn( DataBaseUrl )
Provider = "Provider=Microsoft.Jet.OLEDB.4.0; "
DBPath = "Data Source= " & DataBaseUrl
connstr = Provider & DBPath
Set GetMDBConn=GetConn(connstr)
End Function
' 获得recordset
Function GetRecordSet (sql)
'response.write sql
'response.end
dim rs
set rs= server.CreateObject( "ADODB.Recordset ")
rs.Open sql,conn,1,1 ' <---错误类型:(0x80004005)未指定的错误
Set GetRecordSet = rs
End Function
' 生成Access数据库连接
dbpath=Request.ServerVariables( "APPL_PHYSICAL_PATH ")& "database\news.mdb "
Set conn=GetMDBConn(dbpath)
%>
这是一个conn.asp文件,错误的行已标出
------解决方案--------------------sql= "select top 10 a.*,b.name catalog from newsinfo a,catalog b where a.catalogid=b.id and b.code like ' "&code& "% ' order by isRecomand desc,pubtime desc "
Set Rs=GetRecordSet(sql,objConn)