Mega Search
23.2 Million


Sign Up

Make a donation  
Getting Error while connecting Oracle through DbExpress [Edi  
News Group: embarcadero.public.delphi.database.dbexpress

i'm getting access violation error while connection oracle through DbExpress. Below is my code,
(getting error when executing *Conn.Connected := true;* line)

{code}
procedure TForm1.Button1Click (Sender: TObject);
var
  conn: TSQLConnection;
  Query: TSQLQuery;
begin
  Conn := TSQLConnection. Create (nil);
  try
    Conn.ConnectionName := 'OracleConnection';
    Conn.DriverName := 'Oracle';
    Conn.GetDriverFunc := 'getSQLDriverORACLE';
    Conn.KeepConnection := true;
    Conn.LibraryName := 'dbxora30.dll';
    Conn.LoginPrompt := false;
    Conn.VendorLib := 'oci.dll';
    Conn.Params.Add ('HostName=orcl');
    Conn.Params.Add ('Database=orcl126');
    Conn.Params.Add ('User_Name=snt_live');
    Conn.Params.Add ('Password=log');
    *Conn.Connected := true;*
    Query := TSQLQuery. Create (nil);
    try
      Query.SQLConnection := Conn;
      Query.GetMetadata := true;
      Query.CommandText := 'Select xmlagg ((xmlelement (e, docid || '','')).extract (''//text()'')).getclobval() '+
                           ' from localgrnhdr lg, localgrndtl ld '+
                           ' where lg.cancel = ''F'' and lg.localgrnhdrid = ld.localgrnhdrid and  rownum <= 5';
      Query.Open;
      Query.First;
      while not Query.Eof do begin
        //do some thing
        Query.Next;
      end;
      Query.Close;
    finally
    Query.Free;
    end;
    Conn.Connected := false;
  finally
  Conn.Free;
  end;
end;
{code}

Please give me a solution.

Edited by: karthik thirumoorthi on Sep 24, 2014 4:41 AM

Edited by: karthik thirumoorthi on Sep 24, 2014 5:02 AM

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 24-Sep-2014, at 5:05 AM EST
From: karthik thirumoorthi
 
Re: Getting Error while connecting Oracle through DbExpress  
News Group: embarcadero.public.delphi.database.dbexpress
HAve you tried to define a datamodule and populate it with a tSQLConnection and add those components and setup the same and then try to connect by setting the sqlconnection to true?

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 11-Nov-2014, at 2:42 AM EST
From: Alf Christophersen