补充一点,偶的ID,偶的密码通过ODBC完全可以和ODBC建立连接。
同时TNS服务名也正确,主要看
由于系统错误 5 (Oracle in OraHome92),导致不能加载指定驱动程序。 /conn.asp,行5 是什么问题呢?

解决方案 »

  1.   

    下面将简单介绍一下几种ADO连接方式:ODBC DSN,ODBC DSN-Less, 
    OLE DB Provider,和"MS Remote" Provider.
    1。ODBC DSN连接
    I.DSN
        oConn.Open "DSN=AdvWorks;" & _ 
            "UID=Admin;" & _ 
            "PWD=;"
    注意:从MDAC2.1开始就不能够在使用这样的方式了,就是只把DSN文件名放在ConnectString中
          你必须同时使用DSN,UID,PWD标志。例如下面的方式在MDAC 2.1中将会出错:
        oConn.Open "AdvWorks"II.File DSN
        oConn.Open "FILEDSN=\somepath\mydb.dsn;" & _ 
            "UID=Admin;" & _
            "PWD=;"
    III.ODBC DSN-Less Connections
    a)ODBC Text Driver
        oConn.Open _
            "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
            "Dbq=\somepath\;" & _
            "Extensions=asc,csv,tab,txt;" & _
            "Persist Security Info=False"
    注意:需要在SQL语句中指定使用到的文件名。例如:
        oRs.Open "Select * From customer.csv", _
            oConn, adOpenStatic, adLockReadOnly, adCmdText
    b)ODBC Driver for Access
        i)普通安全模式:
            oConn.Open _
                "Driver={Microsoft Access Driver (*.mdb)};" & _ 
                "Dbq=\somepath\mydb.mdb;" & _
                "Uid=Admin;" & _
                "Pwd=;"
        ii)如果使用了System database:
            oConn.Open _
                "Driver={Microsoft Access Driver (*.mdb)};" & _ 
                "Dbq=\somepath\mydb.mdb;" & _
                "SystemDB=\somepath\mydb.mdw;", _
                "admin", ""
    c)ODBC Driver for SQL Server
        i)普通安全模式
            oConn.Open "Driver={SQL Server};" & _ 
                "Server=carl2;" & _
                "Database=pubs;" & _
                "Uid=sa;" & _
                "Pwd=;"
        ii)使用信任安全模式:
            oConn.Open "Driver={SQL Server};" & _ 
                "Server=carl2;" & _
                "Database=pubs;" & _
                "Uid=;" & _
                "Pwd=;"
        注意:要使用空白的Uid和Pwd          
    d)ODBC Driver for Oracle
        i)使用现有的Oracle ODBC Driver from Microsoft:
            oConn.Open _
                "Driver={Microsoft ODBC for Oracle};" & _
                "Server=OracleServer.world;" & _
                "Uid=demo;" & _
                "Pwd=demo;"
        ii)使用老版本的Oracle ODBC Driver from Microsoft:
            oConn.Open _
                "Driver={Microsoft ODBC Driver for Oracle};" & _
                "ConnectString=OracleServer.world;" & _
                "Uid=demo;" & _
                "Pwd=demo;"
    IIII)使用微软的OLE DB Data Link Connections方式Data Link File (UDL)
    a)使用绝对路径
        oConn.Open "File Name=\somepath\pubs.udl;" 
    b)使用相对路径
        oConn.Open "File Name=pubs.udl;" 
    V)OLE DB Provider Connections方式
    a)OLE DB Provider for ODBC Databases
        i)Access (Jet):
            oConn.Open _
                "Provider=MSDASQL;" & _ 
                "Driver={Microsoft Access Driver (*.mdb)};" & _
                "Dbq=\somepath\mydb.mdb;" & _
                "Uid=Admin;" & _
                "Pwd=;"
        ii)SQL Server:
            oConn.Open _
                "Provider=MSDASQL;" & _  
                "Driver={SQL Server};" & _
                "Server=carl2;" & _
                "Database=pubs;" & _
                "Uid=sa;" & _
                "Pwd=;"
    b)OLE DB Provider for Microsoft Jet  (Access)
        i)普通安全模式:
            oConn.Open _
                "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=\somepath\mydb.mdb;" & _ 
                "User Id=admin;" & _
                "Password=;"
        ii)如果使用了System database:
            oConn.Open _
                "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=\somepath\mydb.mdb;" & _ 
                "Jet OLEDB:System Database=system.mdw;", _
                "admin", "" 
        注意:当使用OLE DB Provider4.0版本是,需要把MDB和MDW文件转换成4.0的数据库格式
        iii)如果MDB需要一个数据库密码的话:
            oConn.Open _
                "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=\somepath\mydb.mdb;" & _ 
                "Jet OLEDB:Database Password=MyDbPassword;", _
                "admin", ""
    c)OLE DB Provider for Excel Spreadsheet: 
            oConn.Open _
                "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=\somepath\expenses.xls;" & _
                "Extended Properties=""Excel 8.0;HDR=Yes;"";" 
        注意: "HDR=Yes"表示在第一行中是行标题,在provider中将不把第一行包括入recordset中
    d)OLE DB Provider for SQL Server
        i)普通安全模式:
            oConn.Open "Provider=sqloledb;" & _ 
                "Network Library=DBMSSOCN;" & _
                "Data Source=carl2;" & _
                "Initial Catalog=pubs;" & _
                "User Id=sa;" & _
                "Password=;"
        ii)使用信任安全模式:
            oConn.Open "Provider=sqloledb;" & _
                Network Library=DBMSSOCN;" & _
                "Data Source=carl2;" & _
                "Initial Catalog=pubs;" & _
                "Trusted_Connection=yes;"
        注意:"Network Library=DBMSSOCN"声明OLE DB使用TCP/IP替代Named Pipes.
    e)OLE DB Provider for Oracle
        oConn.Open "Provider=msdaora;" & _
            "Data Source=OracleServer.world;" & _ 
            "User Id=sa;" & _
            "Password=;"
    (VI)Remote OLE DB Provider Connections方式(就是我一直在研究的RDS方式哦,呵呵。):
    a)MS Remote - Access (Jet)
        i)ODBC DSN:
            oConn.Open "Remote Server=http://carl2;" & _ 
                "Remote Provider=MSDASQL;" & _
                "DSN=AdvWorks;" & _
                "Uid=admin" & _
                "Pwd=;" 
        ii)OLE DB Provider:
            oConn.Open "Provider=MS Remote;" & _ 
                "Remote Server=http://carl2;" & _
                "Remote Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=\somepath\mydb.mdb;", _
                "admin", ""
        iii)OLE DB Provider自定义事务对象
            oConn.Open "Provider=MS Remote;" & _ 
                "Remote Server=http://carl2;" & _
                "Handler=MSDFMAP.Handler;" & _
                "Data Source=MyAdvworksOLEDBConnectTag;"
    b)MS Remote - SQL Server
        i)ODBC DSN:
            oConn.Open "Remote Server=http://carl2;" & _ 
                "Remote Provider=MSDASQL;" & _
                "Network Library=DBMSSOCN;" & _
                "DSN=Pubs;" & _
                "Uid=sa" & _
                "Pwd=;" 
        ii)OLE DB Provider
            oConn.Open "Provider=MS Remote;" & _ 
                "Remote Server=http://carl2;" & _
                "Remote Provider=SQLOLEDB;" & _
                "Network Library=DBMSSOCN;" & _
                "Data Source=carl2;" & _
                "Initial Catalog=pubs;" & _
                "User ID=sa;" & _
                "Password=;"
      

  2.   

    Set OraSession = CreateObject("OracleInProcServer.XOraSession")     
    Set WebOraDatabase = OraSession.DbOpenDatabase("sid","uid/pwd",0)
      

  3.   

    Set OraSession = CreateObject("OracleInProcServer.XOraSession")     
    Set WebOraDatabase = OraSession.DbOpenDatabase("sid","uid/pwd",0)这样应该可以阿
      

  4.   

    armyyd(不会游泳的猫)  ,辛苦了,我只想通过ODBC中的Oracle in oraHome92驱动与9i建立连接,你提供的ODBC连接不适合于9i。
    marvinhong(边城骆驼) and yujiabian(流氓兔子雨) ,我想通过ODBC连接。
      

  5.   

    不是吧我给的就是asp通过odbc连接的啊如果没有建立系统dsn,你在asp里当然连不通了。
      

  6.   

    armyyd(不会游泳的猫):偶的是Oracle 9i,需要通过ODBC中的Oracle in oraHome92驱动与9i建立连接,我已经建立了系统dsn,测试也成功。但就是用ASP语句连接不上。
    语句如下:
    dim conn
    Set conn = Server.CreateObject("ADODB.Connection")conn.open "DSN=;dbq=;Uid=;Pwd="或者
    conn.open "DSN=;Uid=;Pwd="但就是连接不上错误如下:
    Microsoft VBScript 编译器错误 错误 '800a03f6' 缺少 'End' /iisHelp/common/500-100.asp,行242 Microsoft OLE DB Provider for ODBC Drivers 错误 '80004005' 由于系统错误 5 (Oracle in OraHome92),导致不能加载指定驱动程序。 /conn.asp,行5 
      

  7.   

    难道没人遇到过此类问题吗?
    是系统配置的问题?如果是,那在ODBC中的测试应该不会连接成功!
    还是程序代码的问题?
    请大家分析一下。
      

  8.   

    原来是Oracle 9i的一个BUG,本人已经顺利解决。这个问题是Oracle9i 装到NTFS文件系统下的权限问题。解决方法就是:把oralce主目录的安全属性中的Authenticated Users下的读取及运行、列出文件夹目录、读取选项去掉之后,再选上,然后点击应用就OK了。
    Oracle 公司的原版資料: 
    Problem Description ------------------- 
    When running an application that connects to Oracle and uses the Authenticated User privilege (such as Microsoft's Internet Information Server (IIS)) via Oracle's 9.2 client software and any of these programmatic interfaces 
    1. Oracle Provider for OLE DB 
    2. Microsoft OLE DB Provider for Oracle 
    3. Oracle ODBC Driver 
    4. Microsoft ODBC for Oracle 
    5. Oracle Objects for OLE (OO4O) you will receive one of the following errors: 
    (1) Oracle Provider for OLE DB 
    Error Type: Microsoft OLE DB Service mponents (0x80070005) Access is denied. 
    (2) Microsoft OLE DB Provider for Oracle 
    Error Type: Microsoft OLE DB Provider for Oracle (0x80004005) Oracle client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3.3 or later client software installation. Provider is unable to function until these components are installed. Or Error Type: Microsoft OLE DB Provider for Oracle (0x80004005) Oracle error occurred, but error message could not be retrieved from Oracle. 
    (3) Oracle ODBC Driver 
    Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Specified driver could not be loaded due to system error 5 (Oracle in OraHome92). 
    (4) Microsoft ODBC for Oracle The Oracle(tm) client and networking components were not found. These components are supplied by Oracle Corporation and are part of the Oracle Version 7.3 (or greater) client software installation. You will be unable to use this driver until these components have been installed. (5) Oracle Objects for OLE (a) while using a GLOBAL.ASA file Error Type: Active Server Pages (0x0) An error occurred while creating object 'OraSession'. (b) not using a GLOBAL.ASA file Error Type: Microsoft VBScript runtime (0x800A0046) Permission denied: 'CreateObject' 
    (6) Other miscellaneous errors (a) The Specified Module Could Not Be Found Solution Description 
    -------------------- You need to give the Authenticated User privilege to the Oracle Home by following these steps: 
    1. Log on to Windows as a user with Administrator privileges.
    2. Launch Windows Explorer from the Start Menu and and navigate to the ORACLE_HOME directory. 
    3. Right-click on the ORACLE_HOME folder and choose the "Properties" option from the drop down list. A "Properties" window should appear. 
    4. Click on the "Security" tab on the "Properties" window. 
    5. Click on "Authenticated Users" item in the "Name" list (on Windows XP the "Name" list is called "Group or user names"). 
    6. Uncheck the "Read and Execute" box in the "Permissions" list (on Windows XP the "Permissions" list is called "Permissions for Authenticated Users"). This box will be under the "Allow" column. 
    7. Check the "Read and Execute" box. This is the box you just unchecked.
    8. Click the "Apply" button. 
    9. Click the "OK" button. 
    10. You may need to reboot your computer after these changes have been made. Re-execute the application and it should now work. Explanation ----------- If you install Oracle9i Release 2 (9.2.0.1) on a computer running Windows with an NTFS partition, the contents of ORACLE_HOME directory will not be visible to users who are authenticated on that machine. These permissions were not set properly when the software was installed. Applications that were working fine with previous versions of Oracle software will stop working when they upgrade to Oracle 9.2. NOTE: The application will continue to work if the user has logged onto the machine as an Administrator. Any application that is using the Authenticated User privilege will not work. A notable example would be IIS which might service some of the requests based on the Authenticated User privileges. To demonstrate the problem in further detail, you can log on to the operating system as an authenticated machine user. You won't be able browse the contents of the ORACLE_HOME directory demonstrating your inability to load any Oracle DLLs or make a connection. References 
    ---------- Bug:2498880 - Oracle 9I Release 2 Installation Issue on Windows 2000 NTFS File System Additional Search Words ----------------------- OLEDB