使用asp-classic连接accdb数据库

时间:2013-04-11 15:51:47

标签: database ms-access asp-classic

我尝试使用asp-classic将数据库连接到我的网页。我在使用.mdb文件之前成功了,但现在我有一个新的数据库格式为accdb,需要是因为.mdb文件中不支持的功能。

我用于完美运行的.mdb连接的代码。

<%@Language=VBScript %>
<%
Dim adoCon
Dim rsLogbook
Dim strSQL
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("DatabaseName.mdb")
Set rsLogbook = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT TableName.FieldName FROM TableName;"
rsLogbook.Open strSQL, adoCon
Response.Write ("<br>")
Response.Write (rsLogbook("FieldName"))
rsLogbook.Close
Set rsLogbook = Nothing
Set adoCon = Nothing
%>

我尝试用“accdb”替换“.mdb”但没有运气。任何帮助表示赞赏:)

1 个答案:

答案 0 :(得分:1)

在寻找数据库连接的正确语法时,

ConnectionStrings.com通常是一个非常好的起点。

您将“.mdb”更改为“.accdb”的位置?你有以下几点吗?

adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb, *.accdb)}; DBQ=" & Server.MapPath("DatabaseName.accdb")

修改

查看错误(“用于ODBC驱动程序的Microsoft OLE DB提供程序错误'80004005'”)后,这篇知识库文章似乎可以解释该问题并解决方法:http://support.microsoft.com/kb/926939