qry.connection = ac1;
ds1.dataset = qry;ADO连接Oracle数据库时,测试时讲连接好了。程序运行时出现:
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleException with message 'ORA-06413: 连接未打开'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------
也就是我想知道怎么使用ADO连接Oracle数据库,希望兄弟姐妹告知。
小弟我刚开始接触Oracle与delphi希望大家讲明白点。谢谢。
unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DB, ADODB, StdCtrls;type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    ds1: TDataSource;
    ac1: TADOConnection;
    qry: TADOQuery;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}function OpenQuery(query:TADOQuery;SqlStr:string;ShowMsg:boolean=true):boolean;
begin
    query.close;
    query.Filter := '';
    query.Filtered := false;
    query.sql.clear;
    query.sql.add(sqlstr);
    try
      query.open;
    except
      if ShowMsg then ShowMessage('打开'+query.name+'出错,sql语句为:'+sqlstr);
      result := false;
      exit;
    end;
    result := true;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
   str : string;
begin
   str := 'select * from tin_cm ';
   if not OpenQuery(qry,str) then exit;
   with qry do
   begin
   edit1.Text := fieldbyname('cm_name').AsString;
   end;
end;end.

解决方案 »

  1.   

    不关你上面代码的事
    你是怎么连接数据库的就是那段connectionstring
    可能是那里有错数据库是在本地还是在远程?
      

  2.   

    是在局域网里,用ADOConnection连接后,测试没有问题,是不是我哪里没有设置。
      

  3.   

    adoconnection1.connectionstring:='Provider=OraOLEDB.Oracle.1;Password=yourpassword;Persist Security Info=True;User ID=uername;Data Source=servername';
      

  4.   

    你的query没有连上adoconnection吧
      

  5.   

    Provider=OraOLEDB.Oracle.1;Password=rccrm;Persist Security Info=True;User ID=rccrm;Data Source=rccrm
      

  6.   

    ADOConnection.Connected:=true;,这个一定要设置吗
      

  7.   

    ADOConnection.Connected:=true;,这个一定要设置吗不一定要的
      

  8.   

    到我的网站上去下载DOA组件吧,Delphi开发Oracle --- 一流!
    msn:[email protected]
    http://wwdn.kmip.net
      

  9.   

    问题已经搞定,只是重新做了一遍就可以了,可能是前一次哪个设置错了把。
    问一下要想让dxDBEdit只能输入数字,应该怎么设置