请问在delphi中如何连接oralce数据库,最好能说的细一点,不要只说用ado或bde或odac控件连接,能不能说说具体的连接细节。解决问题一定给分,分数不够还可以再加,请大家帮忙,谢谢。

解决方案 »

  1.   

    用BDE不用安装客户端,如果用ADO的话要安装客户端,
    连接方式和连接SQL一样,只是用的驱动不一样!!
      

  2.   

    楼上的( ziqing(delphi转.net中))说的“用BDE不用安装客户端”是错的...用odac的一种方式可以不用安装客户端..还有就是 连接Oracle有好多种方法,不过每种都是大同小异....建个ODBC数据源很难吗???? -_-b  BS楼主
      

  3.   

    楼上!请问!!
    用ODBC中的哪种方法可以不用安装客户端!??
      

  4.   

    楼主,按照我的经验,客户端是至少要安装的。
    然后连接字符串可以这样写(ADO的方式,我的Oracle是9i版的):
    "Provider=OraOLEDB.Oracle.1;Persist Security Info=True;User ID=登录用户名;Password=登录密码;Data Source=数据库服务名",其中Provider部分也可以写成MSDAORA.1,但根据我的经验这个驱动经常出错。
      

  5.   

    ORACLE可以不用ODBC配置数据源的啊,直接在BRLAND公司自带的BDE上配置就可以了,驱动选择ORACLE驱动,如果用ADO控件的话,那根本就不需要配置,直接双击控件,在跳出窗口里面的单击STRING选择ORACLE驱动和您的数据库就可以直接使用了,如果程序里要该数据源的话您可以用CONNECTSTRING属性,例如:ADOCOMMENT.CONNECTSTRING:=‘’;引号里的内容可以按刚刚说的方法做一便,然后到里面拷贝,不需要特别的记忆。如果您用的是BDE控件的话,那我觉得还是要配置数据源的拉。在控件的DATABASE里选择您的ORACLE客户端数据库,要是有TABLE或其他控件的话,也需要选择,或在代码里附值。问题也不难,多搞几次就会了。
      

  6.   

    接着来,楼主你可以是使用ADO面板上的ADOConnection控件,然后设置其ConnectionString为上面我说的连接字符串,然后设置其Connected := True;
    搞定!
      

  7.   

    好的,谢谢大家,我连通了以后一定给分,大家不要着急,如果还有什么好的方法也请大家继续告诉我,不知道不安装oracle客户端是否能够连接另外各位老兄学oracle的时候都看了什么书,能推荐基本吗?最好是数据库管理和数据库开发方面的都推荐基本,最好有电子版可以下载的,谢谢:)
      

  8.   

    再RFA接说,然后您用的其他ADO控件就可以连到刚刚建的ADOconnection里了以后的其他控件就不用每个都设置CONNECTIONSTRING属性了,方便,同样在BDE里面也可以用DATABASE实现该功能,只要在ALICES里选你需要的数据源,在DATABASENAME里自定义数据源名,该数据源名只是在本程序内使用,其他地方无效,配好后,就可以在其他BDE的DATABASE里看到刚刚配置的数据源名就可以了。
      

  9.   

    哈哈,我不看书的,请教旁边高手,另加自己摸索,还有就到CSDN逛逛拉,看书太累了,没乐趣好言啊。
      

  10.   

    如果不想安装Oracle客户端,就用odac,设置也很简单... 自己试试以后编程靠自己还是多些 ^^!
      

  11.   

    楼上大侠,用ODBC中的哪个驱动可以实现您所说的不用安装客户端就能连接Oracle??
      

  12.   

    可以使用简单的客户端,连接也稳定,使用bde的简易客户端可以到www.playicq.com下载,连接挺方便的
      

  13.   

    rfa(实况狐狸) 老大!!! 你能看清或能区别 odac 与 odbc 这几个简单的ASCII字母吗????
      

  14.   

    其实不管什么连接配置都类似:你先要有Oracle客户端,然后
    配置Oracle的,Net Configuration assistant建立网络数据库服务器的VHF
    具体配置,不同Oracle版本不同,8.05和8i就不一样。
    不过就是建立一个本地网络服务名,网络服务名字为你安装时候的数据库名字
    默认是ORCL,用TCP/IP连接,然后输入IP地址或者你的配置文件名字。
    然后就是测试,通过之后为这个连起一个你喜欢的名字。
    Oracle部分就OK了。
    之后
    进入Delphi用 BDE,ADO,DBExpress
    看你的需要,BDE连接复杂一点,
    要到BDE里面建立一个Oracle的连接驱动
    以ADO为例子:
    你放置好了Connection
    到了选择驱动画面:你选择
    Oracle provide For OLE DB
    然后出现一个下一个画面:
    DataSource:就是你刚刚建立的VHF名字
    输入User_Name和Password测试连接就可以了
      

  15.   

    如果还不清楚我就可以制作一个Word文件发给你。
      

  16.   

    我比较关心的还是不用安装客户端的那种连接方法。发给我吧 [email protected]
      

  17.   

    WoKao~~~ 不是吧,这么多马甲?? ^_^
      

  18.   

    CDSoftwareWj(95927) 老大,odac 是什么东西,你能讲清楚点吗
      

  19.   

    Oracle Data Access Components 3.60
    Copyright 1997-2001, Core Lab. All Rights Reserved
    --------------------------------------------------Oracle Data Access Components (ODAC) library offers some nonvisual
    components for Borland Delphi, C++ Builder and Kylix. They serve
    for access to Oracle RDBMS. ODAC is an alternative to standard
    way processing data by Borland Database Engine (BDE).ODAC uses Oracle Call Interface (OCI) directly. The Oracle Call
    Interface is an application programming interface (API) that allows
    an application developer to use a third-generation language's native
    procedure or function calls to access the Oracle database server and
    control all phases of SQL statement execution. The OCI provides a
    library of standard database access and retrieval functions in the
    form of a dynamic runtime library, ORA*.DLL, that can be linked in
    by the application.
    Also with Net option ODAC allows to connect without Oracle client
    software installed on workstation. In such case ODAC requires only
    TCP/IP protocol and allows to build really thin database application.
     
    Using BDE in Oracle oriented client/server applications has some
    deficiencies. So in consequence of BDE community get unable server
    specific features, use more resources, reduce speed of processing
    data, cumbrous distribution of an application and its administration.In case of using BDE transfer way of data is:[Oracle RDBMS] <> [SQL*Net] <> [OCI] <> [SQL Links] <> [BDE] <> [Application]ODAC works directly through Oracle Call Interface. It allows to
    avoid using BDE and SQL Links: [Oracle RDBMS] <> [SQL*Net] <> [OCI] <> [Application]ODAC Net provides optimal transfer way: [Oracle RDBMS] <> [TCP/IP] <> [Application]Version 3.50 of ODAC includes following components:  TOraSession - controls server connection;
      TMemDataSet - base class for TOraDataSet and TVirtualTable;
      TOraDatSet - base class for TOraQuery and TSmartQuery;
      TOraQuery - queries execution, operates record set, flexible way
        updating database tables;
      TSmartQuery - easy in using and an alternative to TOraQuery,
        automatically builds INSERT, DELETE, UPDATE queries, automatic
        locking and refreshing records;
      TOraSQL - executes SQL statements, PL/SQL blocks, stored procedure;
      TOraPackage - allows to execute package procedures and functions and
        provides access to package variables;
      TOraTable - allows to retrieve and update data single table without 
        writing SQL statement;
      TOraStoredProc - executes stored procedures and functions, allows
        to edit cursor data returned as parameter;
      TOraNestedTable - controls nested table's data;
      TOraProvider - provides data to and applies updates from a client
        dataset;
      TOraScript - executes sequence of SQL and PL/SQL statements;
      TOraAlerter - allows to transfer messages between sessions;
      TOraLoader -  provides quick loading data to Oracle database;
      TOraSQLMonitor - allows to monitor dynamic SQL executing in ODAC
        based applications;
      TOraErrorHandler - translates error messages;
      TBDESession - allows to integrate ODAC components into BDE based
        application;
      TConnectDialog - serves for enter username, password and server name;
      TCRDBGrid - extends TDBGrid capabilities, provides visual access to 
        filters and incremental search;
      TVirtualTable - dataset stores data in memory.Using Oracle Data Access gives you the following advantages: - Doesn't require Oracle's software on client side with Net option;
     - No distributing, installing and configuring the BDE and ODBC; 
     - You can use any Delphi Professional Edition to develop
       client/server applications;
     - Enables you to use many Oracle specific features;
     - Supports Oracle 8 features: BLOB, CLOB and BFile data types,
       objects, arrays, references, nested tables;
     - Simplifies data updating;
     - Offers two way of updating data: more flexible with TOraQuery and
       more easy with TSmartQuery;
     - Speeds up fetch record from database;
     - Provides automatic locking and refreshing records;
     - Allows to execute longtime stored procedure separated thread;
     - Advanced design time editors;
     - Interface (methods, properties) of ODAC components is similar
       to standard BDE data access components (TDatabase, TQuery, ..); 
     - Supports all data-aware components;
     - Uses OraTools Add-in to build and check queries with OraDesigner,
       design and debug PL/SQL blocks with OraDebugger and explore
       database schemas with OraExplorer;
     - and so on.Compatibility
    -------------ODAC supports Oracle 7.3, 8.0, 8i and 9i, including  Personal and Lite.Note: ODAC for Delphi 4 requires Update Pack 3 (Delphi 4 Build 5.108).Installation
    ------------Since ODAC 3.20 run- and design-time packages are separated.
    ODAC installer copies these files to folders where they should be resided.  odacXX.bpl - ODAC run-time package (located in Windows\System folder)
      dclodacXX.bpl - ODAC design-time package (located in Delphi\bin folder)
      oraprovXX.bpl - TOraProvider component (located in Delphi\bin folder)
      crcontrolsXX.bpl - TCRDBGrid component (located in Delphi\bin folder) Delphi  To compile ODAC based application add $(DELPHI)\ODAC\Lib to Project
      Options|Search path. C++ Builder  To compile ODAC based application add $(BCB)\ODAC\Lib to 
      Project Options|Library path and $(BCB)\ODAC\Include to
      Project Options|Include path. Kylix  Select the Kylix Component/Install Packages menu. Press the Add
      button and select the bplodac.so file from the odac directory and
      press OK. Now components are available in the Oracle Access group.
      Add odac/lib directory to Search Path of your project.  TOraProvider component  If you use Delphi or C++ Builder Enterprise edition you can install
      TOraProvider component separately. To do it compile and install
      oraprovXX.bpk package. OraTools add-in  Since ODAC 3.50 there is no design-time package oratoolsXX.bpl.
      OraTools now provided as a separate add-in. It is installed once 
      and can be used by Delphi and C++ Builder. Kylix is not supported
      by now.Trial version restrictions
    --------------------------
      Note following restrictions when using ODAC trial version:
      - when running ODAC based application IDE should be running either
      - if Net option is on only six fields are available in TOraDataSet
      

  20.   

    TO : jblcj(我是谁) 这是我Copy来的,能不能成功不知道,以前的Oracle8.05都是可以不用安装就带文件就能使用了,但是Oracle8i后我就没有试验成功过。如果你试验成功了发个帖子交流一下,这个问题的人太多了。
    1.在安装了Oracle客户端程序后,在Oracle安装目录下有如下目录和文件是连接Oracle数据库服务器所必需的:(最好保持目录层次关系结构) 
    2.Oracle\BIN及子目录文件,并且保证应用程序可以找到该目录,即该目录为系统目录或者PATH目录。 
    3.Oracle\OCOMMON\NLS\ADMIN目录以及其下所有文件 
    4.Oracle\OCOMMON\NLS\MESG目录以及其下所有文件 
    5.Oracle\NETWORK\ADMIN\tnsnames.ora 这个文件是配置网络服务名用的 
    可以用记事本打开,改为正确的配置。 
    6.Oracle\ORACORE\Mesg以及其下所有MSB文件 7.导入注册表到客户机: 
    REGEDIT5 
    [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE] 
    "inst_loc"="C:\\Program Files\\Oracle\\Inventory" 
    "ORACLE_HOME"="D:\\oracle\\ora81" 
    "ORACLE_HOME_NAME"="OraHome81" 
    "API"="D:\\oracle\\ora81\\dbs" 
    "ORACLE_GROUP_NAME"="Oracle - OraHome81" 
    "NLS_LANG"="NA" 
    "OLEDB"="D:\\oracle\\ora81\\oledb\\mesg" 
    "VOBHOME2.0"="D:\\oracle\\ora81" 
    "OO4O"="D:\\oracle\\ora81\\oo4o\\mesg" [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ALL_HOMES] 
    "HOME_COUNTER"="1" 
    "DEFAULT_HOME"="OraHome81" 
    "LAST_HOME"="0" [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\ALL_HOMES\ID0] 
    "NAME"="OraHome81" 
    "PATH"="D:\\oracle\\ora81" 
    "NLS_LANG"="NA" [HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0] 
    "ID"="0" 
    "ORACLE_GROUP_NAME"="Oracle - OraHome81" 
    "ORACLE_HOME_NAME"="OraHome81" 
    "ORACLE_HOME"="D:\\oracle\\ora81" 
    "NLS_LANG"="SIMPLIFIED CHINESE_CHINA.ZHS16GBK" 
    "ORACLE_SID"="QIAODB" //这个要和服务器的sid一致 
    "ORACLE_HOME_KEY"="Software\\ORACLE\\HOME0" 
    "SQLPATH"="D:\\oracle\\ora81\\dbs" 
    "ORACLE_BASE"="D:\\oracle" 
    "MSHELP_TOOLS"="D:\\oracle\\ora81\\MSHELP" 
    "RDBMS_CONTROL"="D:\\oracle\\ora81\\DATABASE" 
    "RDBMS_ARCHIVE"="D:\\oracle\\ora81\\DATABASE\\ARCHIVE" 
    注册表信息要把目录改成相应的目录, 
    我用的Oracle817整个客户端大概30M左右(没有压缩)。 
      

  21.   

    ODAD和DOA 是两个专门用于Oracle的第三方组件,他们采用直接调用OCI操纵Oracle的方式
    所以速度和性能都比BDE,ADO,ODBC要好,不过中文资料比较少。DOA我应用于C/S的项目过,
    效果很好。其他不做评价。
      

  22.   

    几种方式我都试过。连通都是没问题的。
    ADO和BDE,DOA好像都要装oracle客户端。BDE配置更麻烦一些。
    ODAC可以不装客户端。
    但据说ODAC和DOA性能不太好。听说,我自己也不清楚。
    个人感觉用D做Oracle项目用webservice好一些。可以解决程序发布的问题。不然太麻烦了。