【问题标题】:classic ASP Microsoft OLE DB Provider for ODBC Drivers error '80004005'用于 ODBC 驱动程序的经典 ASP Microsoft OLE DB 提供程序错误“80004005”
【发布时间】:2013-04-23 20:47:52
【问题描述】:

我正在将应用程序从 IIS 6 迁移到 IIS 7.5,但遇到了最奇怪的问题:

Microsoft OLE DB Provider for ODBC Drivers error '80004005' 

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified 

/Complaints/Login.asp, line 175 

这是第 175 行附近的代码:

  myConn = getDatabaseConnection()
  set rs = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT * FROM Users WHERE lower(Login) = lower('" & uId & "') and Active = 1"
  rs.Open strSQL, myConn, 3, 3

这里没什么特别的...

这是 db 方法:

function getDatabaseConnection()

    Dim strConnection

        strConnection = "Driver={SQL Server};Server=server.domain.com;Database=cc;uid=acc;pwd=xxx;"

    Set GetDatabaseConnection = Server.CreateObject("ADODB.Connection")
    GetDatabaseConnection.CommandTimeout = 60
    GetDatabaseConnection.ConnectionTimeout = 60
    GetDatabaseConnection.CursorLocation = 3

    GetDatabaseConnection.Open strConnection

end function

这似乎适用于在同一应用程序池 (.NET 1.1) 中运行的类似经典 asp 应用程序

我尝试过:复制粘贴其他应用程序的代码,使用连接字符串代替 db 方法(当然抛出 500),更改应用程序池,谷歌,& 作为另一个踢它在 IIS 6 服务器上工作得很好.

我查看了OLE DB Provider for ODBC Drivers Error "80004005',我的连接字符串似乎正确,我的 ASP.NET 1.1 应用程序池只能在 32 位模式下运行。之前服务器上设置的 DSN 也不相关。

我的应用程序在域 A 上的 IIS 5 和域 A 上的 IIS 6 上运行,但是这个 7.5 服务器在域 B 上。因此我使用的是 FQDN。不过,我还没有进行任何其他特定于域的更改。系统使用上述方法对用户进行身份验证。

编辑:也尝试过

strConnection = "dsn=my32bitdsn;uid=xxx;pwd=xxx;"

我继承了这段代码,并且非常喜欢经典的 ASP,有人可以帮忙吗?

更新代码:

  Dim strConnection, oConn
  'get status 
  set rs = Server.CreateObject("ADODB.Recordset")
  strSQL = "SELECT * FROM Users WHERE lower(Login) = lower('" & uId & "') and Active = 1"
  'rs.Open strSQL, myConn, 3, 3

   strConnection = "Driver={SQL Server};Server=server.domain.com;Database=cc;uid=acc;pwd=xxx;"
  Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.CommandTimeout = 60
    oConn.ConnectionTimeout = 60
    oConn.CursorLocation = 3
    oConn.Open strConnection
  Set rs = oConn.Execute(strSQL)

【问题讨论】:

  • 我尝试过的其他事情:设置 32 位 DSN 并指定它,通过 applicationpoolDefaults 在 IIS 中启用 32 位模式。我在 dsn 上遇到了驱动程序不兼容错误,我通过启用 32 位仅返回到原始错误消息来修复它:(
  • 是的,所有的字段最终都被赋值了。
  • 我向你保证,这不是问题。
  • 您可以拒绝有关 SQL 最佳实践的建议;不要告诉我这与你的问题无关。
  • 显然不会。您需要执行异教仪式才能使其起作用。希望有人能够在下面回答您的问题。

标签: iis asp-classic odbc database-connection


【解决方案1】:

可能只是表面上的改变,但也可能解决这个问题:

Function getDatabaseConnection()
    Dim strConnection, oConn
    strConnection = "Driver={SQL Server};Server=server.domain.com;Database=cc;uid=acc;pwd=xxx;"

    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.CommandTimeout = 60
    oConn.ConnectionTimeout = 60
    oConn.CursorLocation = 3
    oConn.Open strConnection

    Set getDatabaseConnection = oConn
End Function

我一直害怕直接使用函数名会导致不需要的调用或奇怪的结果,所以习惯了上面的方式。

第二件事是您通过没有“设置”将连接分配为非对象,这也可能导致奇怪和意外的问题。将行更改为:

Set myConn = getDatabaseConnection()

希望以上方法之一能解决这个奇怪的问题。

【讨论】:

  • 那是更好的代码,无论如何我都会用它来替换它,但不幸的是它没有解决问题。我认为这与代码无关,因为完全相同的代码适用于不同的应用程序,但如果我可以采取不同的方法,我也愿意。
  • rs.Open strSQL, myConn, 3, 3
  • 很奇怪,这种错误通常是在连接的.Open() 上抛出的。在这种情况下,请尝试将行更改为:Set rs = myConn.Execute(strSQL) 并查看是否可以解决问题。
  • 它看起来像将连接变量移动到登录中并使用 set 方法得到了 asp 抛出 500 并且错误现在可以在 IIS 日志文件中查看: [Microsoft][ODBC_Driver_Manager]_Data_source_name_not_found_and_no_default_driver_specified 。以前的也是,现在它抛出了 500。
  • 我没有注意到,但 500 正在从登录页面中消失,这意味着我认为它通过了登录。我应该可以从这里拿走,谢谢!
【解决方案2】:

我不确定你是否已经解决了这个错误,但如果你想尝试让它抛出一个可读的错误,你可以试试这个作为连接字符串的一部分。

  1. 您的连接字符串显示数据库服务器是 server.domain.com 还是您只是将其放置在那里以替换您的公司信息?

  2. 试试这个:

    dim cn
    Set cn=Server.CreateObject("ADODB.Connection")
    cn.ConnectionString="Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Initial Catalog=dbName;Data Source=(local) or computername;PWD=;Password=yourpassword;"
    on error resume next
    cn.Open
    if err.number <> 0 then response.Write(err.description) 
    on error goto 0
    

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多