×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

ASP Problem

本文发表在 rolia.net 枫下论坛Below is the error that occured when I run ASP to access MS Access database through OBBC. PLease advise me how to fix it.Thanks.

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
/data/readdata.asp, line 10


---ASP file---
<% @LANGUAGE = VBScript %>
<% ' Listing 13.1 Retrieving Product Data from the Northwind Database
Option Explicit
Response.Expires = 0
Dim objConn, objRS, strQuery
Dim strConnection
Set objConn = Server.CreateObject("ADODB.Connection")
'strConnection = "DSN=Northwind;Database=Nwind;"
'strConnection = strConnection & "UID=;PWD=;"
objConn.Open "Northwind"


strQuery = "SELECT Productname, UnitPrice FROM Products "
strQuery = strQuery & "ORDER BY Productname"
Set objRS = objConn.Execute(strQuery)
%>
<HTML>
<BODY>
All products stored in the Products table,
ordered by product name: <BR><BR>
<%
While Not objRS.EOF
Response.Write objRS("Productname") & " ("
Response.Write FormatCurrency(objRS("UnitPrice")) & ")<BR>"
objRS.MoveNext
Wend

objRS.close
objConn.close
Set objRS = Nothing
Set objConn = Nothing
%>
</BODY>
</HTML>更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / ASP Problem
    本文发表在 rolia.net 枫下论坛Below is the error that occured when I run ASP to access MS Access database through OBBC. PLease advise me how to fix it.Thanks.

    Error Type:
    Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
    [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
    /data/readdata.asp, line 10


    ---ASP file---
    <% @LANGUAGE = VBScript %>
    <% ' Listing 13.1 Retrieving Product Data from the Northwind Database
    Option Explicit
    Response.Expires = 0
    Dim objConn, objRS, strQuery
    Dim strConnection
    Set objConn = Server.CreateObject("ADODB.Connection")
    'strConnection = "DSN=Northwind;Database=Nwind;"
    'strConnection = strConnection & "UID=;PWD=;"
    objConn.Open "Northwind"


    strQuery = "SELECT Productname, UnitPrice FROM Products "
    strQuery = strQuery & "ORDER BY Productname"
    Set objRS = objConn.Execute(strQuery)
    %>
    <HTML>
    <BODY>
    All products stored in the Products table,
    ordered by product name: <BR><BR>
    <%
    While Not objRS.EOF
    Response.Write objRS("Productname") & " ("
    Response.Write FormatCurrency(objRS("UnitPrice")) & ")<BR>"
    objRS.MoveNext
    Wend

    objRS.close
    objConn.close
    Set objRS = Nothing
    Set objConn = Nothing
    %>
    </BODY>
    </HTML>更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • 给你一个SQLServer的例子。我想你可能要提供Driver
      connstr= "Provider=SQLOLEDB;DRIVER=SQLServer;SERVER=servername;DATABASE=abcd;UID=sa;PWD=;"
    • ever tried a different odbc driver ? may help
    • Since you already specified DSN in your codes, you'd better check the ODBC DSN settings at your web server. Maybe you need to install the new version of MDAC.
      • Hi, thank you. May I have your E-mail Address?
        • come in pls.
          myraymond2000@yahoo.com