1
votes

I am trying to make a database connection with Oracle using the TADOConnection component. I added a ADOConnection1 to the form. Then I set the Provider property to "SQLOLEDB". Consider username and password of database is 111 and 222 respectively.

Now on the OnShow event of the form I am trying to make the database connection.

I have written a MakeConnection function called by the OnShow event handler:

function Tabc.MakeConnection : boolean;
var 
  ConnString : string;
begin
  result := false;
  try
    ADOConnection1 := TADOConnection.Create(nil);
    ADOConnection1.ConnectionString := ConnString;
    ADOConnection1.LoginPrompt := false;
    ADOConnection1.Open;
    result := true;
  except
    on E : Exception do
    begin
      exit;
    end;
  end;
end;

My question is, what should be the format of the ConnString variable? Should I use "SQLOLEDB" as provider or anything else?

Update:

Earlier I have created a connection to an Microsoft SQL Server whose connection string format is:

Provider=SQLNCLI10.1;Password=222;Persist Security Info=False;User ID= 111;Initial Catalog= abcde;Data Source= datasource\SQLEXPRESS;Initial File Name="";Server SPN=""
1

1 Answers

4
votes

1. Oracle Database provider:

To connect to the Oracle Database you need at least use a different connection provider in your current situation. Microsoft has its own Microsoft OLE DB Provider for Oracle, but it is deprecated and, as it's stated in the reference, you should avoid using it (link to Oracle’s OLE DB provider added by me):

Microsoft OLE DB Provider for Oracle

This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Instead, use Oracle’s OLE DB provider.

The Oracle Provider for OLE DB you can then in your connection string use this way:

Provider=OraOLEDB.Oracle

2. Oracle Database connection string attributes:

To your next question about Oracle Database specific connection string attributes, the best you can do is to follow the reference.