ADOConnection.Provider = ?

How can I best at runtime determine which providers are available on the 
machine (or if any is available at all)?

I have a program that should be installed and run on different machines, 
some of which have 'Microsoft.ACE.OLEDB.12.0' (in which case I shall need 
this), and some of which only have 'Microsoft.Jet.OLEDB.4.0'.

Is there an easy means available (other than browsing the registry for more 
or less obvious keys) to find out the providers that are installed and 
available?

regards Sven
0
Sven
11/18/2008 11:29:03 AM
embarcadero.delphi.ado 597 articles. 1 followers. Follow

11 Replies
1457 Views

Similar Articles

[PageSpeed] 47

Hello Sven

> Is there an easy means available (other than browsing the registry
> for more or less obvious keys) to find out the providers that are
> installed and available?

Use ADODB.GetProviderNames.

With best regards,
Dmitry Arefiev
AnyDAC Team

RemObjects Software
The Infrastructure Company
http://www.remobjects.com
0
Dmitry
11/18/2008 12:10:09 PM
Thanks a lot, I shall try that

regards Sven

"Dmitry Arefiev" <darefiev@da-soft.com> wrote in message 
news:44968@forums.codegear.com...
> Hello Sven
>
>> Is there an easy means available (other than browsing the registry
>> for more or less obvious keys) to find out the providers that are
>> installed and available?
>
> Use ADODB.GetProviderNames.
>
> With best regards,
> Dmitry Arefiev
> AnyDAC Team
>
> RemObjects Software
> The Infrastructure Company
> http://www.remobjects.com
0
Sven
11/18/2008 1:05:29 PM
I tried the statement: ADODB.GetProviderNames(fProviders); but all I get is 
Access violation?

The only difference between specifying fProviders as TStrings or 
TWideStrings (either one can be used according to documentation) is that the 
invalid read address is hex 10 or hex 14. There is no problem with 
compilation, and I have been unable to find any problem when checking up on 
the ADODB source.

What can I have missed please?

regards Sven

"Dmitry Arefiev" <darefiev@da-soft.com> wrote in message 
news:44968@forums.codegear.com...
> Hello Sven
>
>> Is there an easy means available (other than browsing the registry
>> for more or less obvious keys) to find out the providers that are
>> installed and available?
>
> Use ADODB.GetProviderNames.
>
> With best regards,
> Dmitry Arefiev
> AnyDAC Team
>
> RemObjects Software
> The Infrastructure Company
> http://www.remobjects.com
0
Sven
11/18/2008 1:34:58 PM
Sven Pran wrote:

> I tried the statement: ADODB.GetProviderNames(fProviders); but all I
> get is Access violation?

Very strange! Maybe you can debug GetProviderNames and see why it
happens.

Or, you can read directly from the registry. I use something like this:

procedure GetOLEDBProviders(OleDBProvidersList: TStrings);
var
  Reg: TRegistry;
  i: Integer;
  SubKeys: TStrings;
  CurKey: string;
  ProviderDesc, ProgID: string;
begin
  OleDBProvidersList.Clear;
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_CLASSES_ROOT;
    if Reg.OpenKeyReadOnly('CLSID') then
    begin
      SubKeys := TStringList.Create;
      try
        Reg.GetKeyNames(SubKeys);
        Reg.CloseKey;
        for i := 0 to SubKeys.Count - 1 do
        begin
          CurKey := 'CLSID\' + SubKeys[i] + '\OLE DB Provider';
          if Reg.KeyExists(CurKey) then
          begin
            if Reg.OpenKeyReadOnly(CurKey) then
            begin
              ProviderDesc := Reg.ReadString('');
              Reg.CloseKey;
            end;
            if Reg.OpenKeyReadOnly('CLSID\' + SubKeys[i] + '\ProgID')
then
            begin
              ProgID := Reg.ReadString('');
              Reg.CloseKey;
            end;
            OleDBProvidersList.Add(ProviderDesc + '=' + ProgID);
          end;
        end;
      finally
        SubKeys.Free;
      end;
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;

This procedure will read OLE DB Providers from the registry and will
return the information in the form of name=value pairs, for instance:

Microsoft OLE DB Provider for SQL Server=SQLOLEDB.1
Microsoft OLE DB Provider for Oracle=MSDAORA.1
....

Hope it helps.

Best regards
0
Alexandre
11/18/2008 1:57:07 PM
Yes, I know about the possibility of reading the registry, but I am not too 
happy about that. The reason is that I feel I cannot trust the various keys 
to be the same across different versions of Windows.

regards Sven

"Alexandre Machado" <aleandre.no@spam.consultbrasil.com.br> wrote in message 
news:45005@forums.codegear.com...
> Sven Pran wrote:
>
>> I tried the statement: ADODB.GetProviderNames(fProviders); but all I
>> get is Access violation?
>
> Very strange! Maybe you can debug GetProviderNames and see why it
> happens.
>
> Or, you can read directly from the registry. I use something like this:
>
> procedure GetOLEDBProviders(OleDBProvidersList: TStrings);
> var
>  Reg: TRegistry;
>  i: Integer;
>  SubKeys: TStrings;
>  CurKey: string;
>  ProviderDesc, ProgID: string;
> begin
>  OleDBProvidersList.Clear;
>  Reg := TRegistry.Create;
>  try
>    Reg.RootKey := HKEY_CLASSES_ROOT;
>    if Reg.OpenKeyReadOnly('CLSID') then
>    begin
>      SubKeys := TStringList.Create;
>      try
>        Reg.GetKeyNames(SubKeys);
>        Reg.CloseKey;
>        for i := 0 to SubKeys.Count - 1 do
>        begin
>          CurKey := 'CLSID\' + SubKeys[i] + '\OLE DB Provider';
>          if Reg.KeyExists(CurKey) then
>          begin
>            if Reg.OpenKeyReadOnly(CurKey) then
>            begin
>              ProviderDesc := Reg.ReadString('');
>              Reg.CloseKey;
>            end;
>            if Reg.OpenKeyReadOnly('CLSID\' + SubKeys[i] + '\ProgID')
> then
>            begin
>              ProgID := Reg.ReadString('');
>              Reg.CloseKey;
>            end;
>            OleDBProvidersList.Add(ProviderDesc + '=' + ProgID);
>          end;
>        end;
>      finally
>        SubKeys.Free;
>      end;
>      Reg.CloseKey;
>    end;
>  finally
>    Reg.Free;
>  end;
> end;
>
> This procedure will read OLE DB Providers from the registry and will
> return the information in the form of name=value pairs, for instance:
>
> Microsoft OLE DB Provider for SQL Server=SQLOLEDB.1
> Microsoft OLE DB Provider for Oracle=MSDAORA.1
> ...
>
> Hope it helps.
>
> Best regards
0
Sven
11/18/2008 2:31:48 PM
Sven Pran wrote:

> I tried the statement: ADODB.GetProviderNames(fProviders); but all I
> get is Access violation?
> 
> The only difference between specifying fProviders as TStrings or 
> TWideStrings (either one can be used according to documentation) is
> that the invalid read address is hex 10 or hex 14. There is no
> problem with compilation, and I have been unable to find any problem
> when checking up on the ADODB source.
> 
> What can I have missed please?
> 
> regards Sven
> 
> "Dmitry Arefiev" <darefiev@da-soft.com> wrote in message 
> news:44968@forums.codegear.com...
> > Hello Sven
> > 
> >> Is there an easy means available (other than browsing the registry
> >> for more or less obvious keys) to find out the providers that are
> >> installed and available?
> > 
> > Use ADODB.GetProviderNames.
> > 
> > With best regards,
> > Dmitry Arefiev
> > AnyDAC Team
> > 
> > RemObjects Software
> > The Infrastructure Company
> > http://www.remobjects.com

try the following
start a new Delphi application,
place a new ListBox component on the form
place a new button on the form
add uses ADODB; under the implementation keyword.
double click on the button and write the following line
  ADODB.GetProviderNames(ListBox1.Items);

Run the application and press the button.
What happens?
-- 
"If Al Gore invented the Internet, I invented spell check."
 -- Dan Quayle
0
IOANNIS
11/18/2008 2:34:47 PM
Very good idea. I did, and it worked as it should.
(Eventually I would probably have tried that myself)

But at least now I have something to verify against.

OH, wait a moment! I never CREATED fProviders! Shit.
(It was a field on my form)

Thanks and regards Sven


"YANNIS KOZIKOPULOS" <none@noware.non> wrote in message 
news:45030@forums.codegear.com...
> Sven Pran wrote:
>
>> I tried the statement: ADODB.GetProviderNames(fProviders); but all I
>> get is Access violation?
>>
>> The only difference between specifying fProviders as TStrings or
>> TWideStrings (either one can be used according to documentation) is
>> that the invalid read address is hex 10 or hex 14. There is no
>> problem with compilation, and I have been unable to find any problem
>> when checking up on the ADODB source.
>>
>> What can I have missed please?
>>
>> regards Sven
>>
>> "Dmitry Arefiev" <darefiev@da-soft.com> wrote in message
>> news:44968@forums.codegear.com...
>> > Hello Sven
>> >
>> >> Is there an easy means available (other than browsing the registry
>> >> for more or less obvious keys) to find out the providers that are
>> >> installed and available?
>> >
>> > Use ADODB.GetProviderNames.
>> >
>> > With best regards,
>> > Dmitry Arefiev
>> > AnyDAC Team
>> >
>> > RemObjects Software
>> > The Infrastructure Company
>> > http://www.remobjects.com
>
> try the following
> start a new Delphi application,
> place a new ListBox component on the form
> place a new button on the form
> add uses ADODB; under the implementation keyword.
> double click on the button and write the following line
>  ADODB.GetProviderNames(ListBox1.Items);
>
> Run the application and press the button.
> What happens?
> -- 
> "If Al Gore invented the Internet, I invented spell check."
> -- Dan Quayle
0
Sven
11/18/2008 2:45:05 PM
A Tstringlist is an object that you must create in your code before using it.
My guess is you did not create it.


> {quote:title=Sven Pran wrote:}{quote}
> I tried the statement: ADODB.GetProviderNames(fProviders); but all I get is 
> Access violation?
> 
> The only difference between specifying fProviders as TStrings or 
> TWideStrings (either one can be used according to documentation) is that the 
> invalid read address is hex 10 or hex 14. There is no problem with 
> compilation, and I have been unable to find any problem when checking up on 
> the ADODB source.
> 
> What can I have missed please?
> 
> regards Sven
> 
> "Dmitry Arefiev" <darefiev@da-soft.com> wrote in message 
> news:44968@forums.codegear.com...
> > Hello Sven
> >
> >> Is there an easy means available (other than browsing the registry
> >> for more or less obvious keys) to find out the providers that are
> >> installed and available?
> >
> > Use ADODB.GetProviderNames.
> >
> > With best regards,
> > Dmitry Arefiev
> > AnyDAC Team
> >
> > RemObjects Software
> > The Infrastructure Company
> > http://www.remobjects.com
0
Brian
11/18/2008 11:46:13 PM
"Brian Bushay" wrote in message news:45303@forums.codegear.com...
>A Tstringlist is an object that you must create in your code before using 
>it.
> My guess is you did not create it.

That was exactly what I had forgotten (as I reported in a later post).

regards Sven
0
Sven
11/19/2008 12:12:46 AM
> {quote:title=Sven Pran wrote:}{quote}
> Yes, I know about the possibility of reading the registry, but I am not too 
> happy about that. The reason is that I feel I cannot trust the various keys 
> to be the same across different versions of Windows.

In fact, Registry is the place where ADO gets that information. If you change some of the keys it will not be listed as an installed OLE DB Provider anymore. ;)
But you are right. If GetProviderNames is all you need, you should use it.

Regards
0
Alexandre
11/19/2008 6:31:21 AM
"Alexandre Machado" wrote in message news:45400@forums.codegear.com...
>> {quote:title=Sven Pran wrote:}{quote}
>> Yes, I know about the possibility of reading the registry, but I am not 
>> too
>> happy about that. The reason is that I feel I cannot trust the various 
>> keys
>> to be the same across different versions of Windows.
>
> In fact, Registry is the place where ADO gets that information. If you 
> change some of the keys it will not be listed as an installed OLE DB 
> Provider anymore. ;)
> But you are right. If GetProviderNames is all you need, you should use it.
>
> Regards

It is. Primarily I want to know if the new Microsoft ACE engine is installed 
or if I have to depend on the JET engine, and adapt my application 
correspondingly.

This brings attention to what I consider a deficiency in Delphi 2007 (which 
I still use): I miss a comprehensive and easy to use survey of available API 
functions and procedures.

So why didn't I just look up "ADODB Members" in the online documentation? 
Because I was working with TADOConnect and found no hint under 
TADOConnect.Provider. At the time I frankly didn't think of going to ADODB 
for such information. Obviously I should have ought to.

I suppose that eventually I might have stumbled on to that information 
anyway, but now usenet assistance brought me the answer right away.

And thanks to all those who bothered with helping me.

regards Sven
0
Sven
11/19/2008 10:56:47 AM
Reply:

Similar Artilces:

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

Delphi 6 to Delphi 2010 upgrade and ADO
We have an application written in Delphi 6 Professional that uses ADO to access databases servers that may be on other PCs in our network. We want to move to Delphi 2010 but can't decide if we need Professional or Enterprise. 2010 Pro has dbGO - will this give us the same functionality as the ADO components we use in Delphi 6 Pro? Thanks, Keith > 2010 Pro has dbGO - will this give us the same functionality as the > ADO components we use in Delphi 6 Pro? Yes. > {quote:title=Joachim Uersfeld wrote:}{quote} > > 2010 Pro has dbGO - will this give us the same func...

ASA7 ADO & Delphi ADO ?? Anyone is using it?
Any comments? Is it working? Any Problems? Thanks Hi, PR <noemail@no.com> schrieb in im Newsbeitrag: BoTThJaq$GA.89@forums.sybase.com... > Any comments? Is it working? Any Problems? I tried to connect to ASA7 via the new OLE DB - Provider and ADOExpress from Delphi 5.01. No chance. Only the error message 'Invalid Enum Value'. About the new provider I haven't heard anything good until now... Regards Frank Frank, I've experienced the same problem with the ASA 7 OLEDB Provider. I'm not sure if this is a bug in the AsaProvider or Delp...

ASA ADO Provider
How do I install the ASA ADO Provider without the CD? What files do I need, and do I need to create regisrty entries and register files with windows? ...

Delphi 5 with ADO
Hi I'm having some problems adjusting a Delphi5/MSSQL database application, which i did not wrote (what's more: i'm not a Delphi expert either) so i thought maybe someone in this comunity will enlighten me. It' about an SQL command which is issued by this delphi5 application (the sql command was traced in SQL server with profiler), but which is nowhere to be found in the souce code. I've searched already all the components which i knew that could issue the SQL command (TADOQuery, TADOCommand) but with no l uck. Could anyone tell me other misterious places where i shou...

VS2005
Hi I have tried to run the SimpleCE sample located under the directory C:\Programme\Sybase\SQL Anywhere 9\Samples\ASA\ADO.NET\SimpleCE\. When i try running the sample 6 errors occurs, all like this one: Compilerfehler CS0012 Fehler 1 Der Typ "System.ComponentModel.Component" ist in einer nicht referenzierten Assembly definiert. F�gen Sie einen Verweis auf die Assembly "System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=969db8053d3322ac" hinzu. C:\Programme\Sybase\SQL Anywhere 9\Samples\ASA\ADO.NET\SimpleCE\Form1.cs 79 4 SimpleCE Current version ...

ADO.NET Providers
I'm setting up a new Database profile for ADO.NET, using the 'System.Data.Oledb' namespace. You must choose a data provider. My questions is where is this list of providers?, Can you add to them or are they a static list provided by Sybase/Powerbuilder 10.5 ...

ADO.Net Provider
Excuse me if this post is to the wrong group. We are currently using ODBC to connect to our Sybase database in our .Net application. We are finding this to be slow and was wondering if there is an ADO.Net Provider for Sybase. Does the DataWindow.Net product offer this? Any help would be greatly appreciated, Thank you, Raymond Look at: http://www.carlprothman.net/Default.aspx?tabid=81 or http://www.connectionstrings.com/ Yossi Dallal "Ray" <raymondc@symmetrics.net> wrote in message news:42b83bd3$1@forums-2-dub... > Excuse me if this post is to ...

ASA7, ADO and Delphi
Hello! I've got a problem with accessing a database via ADO with Delphi 5. Everytime I set the ADOConnection active I get the error "Invalid enum value". I'm using Delphi 5 Enterprise and ASA7 with EBF #449. Is there anybody who ever get an ADOConnection to ASA7 with Delphi 5? Gruesse, Matthias I'm using C++ Builder 5 and get the same problem. I've asked this question before and no one seems to be able to respond... Matthias Hovestadt wrote: > Hello! > > I've got a problem with accessing a database via ADO > with Delp...

Search providers page does NOT provide search providers!
Name: John A. Bilicki III Email: jab_creationsatyahoodotcom Product: Minefield Summary: Search providers page does NOT provide search providers! Comments: I can not find the search providers on the search providers page! There are nothing but extensions now! Change it back! Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9pre) Gecko/2008033105 Minefield/3.0pre From URL: http://hendrix.mozilla.org/ ...

ID-Provider : ID-Provider OR Unique digit provider?
Windows Server 2003 R2 Novell Identity Manager 3.6 eDirectory 8.8 SP3 Text phrase from ID-Provider driver documentation (IDM3.6): "There are many different reasons why you would want to use the ID Provider driver. For example: &#138; For administrators it is convenient to have one basic ID for each objects in the system, and to have complete control of the ID. No other system can change this ID." My Questions: #1: For Complete Control of IDs: Can I query ID-Provider Server(RMI) to give me report for which users has which IDs generated and their ID-po...

ADO.Net Data Provider
We are currently using an ODBC driver to connect to a Sybase database... we're wondering -- has anyone seen or can recommend an ADO.Net Data Provider? Thank you, Raymond Hi Ray, For Sybase ASE 12.X there is an ASE ADO.NET Data Provider, a native ado.net provider. This is included in the Sybase SDK (for ASE) for Windows Clients -pv "Ray" <raymondc@symmetrics.net> wrote in message news:42b8362a$1@forums-2-dub... > We are currently using an ODBC driver to connect to a Sybase database... > we're wondering -- has anyone seen or can recomm...

ADO provider is very slow, unstable?
Before you ask: our environment is ASA7.01 EBF1143 on WinNT SP6a Today we were playing around with the OLE DB provider for ASA (i.e. not the MS provider that just uses ODBC). We were testing it using ADO from Crystal Reports. Two observations: 1. It was painfully slow in reading the result set, and seemed to do the record selection (i.e. where clause processing) on the client side!! 2. Crystal Reports process just completely vanished several times, usually when trying to place the columns that come from Java objects in the DB. This may or may not be related to a problem of col...

ADO not ADO.NET
Hi, I have to connect to a db using adodb (which i select from the references). I have to retrieve the car models from the database and bind them to a listbox. I am not sure how to proceed and I can't find any articles on ADO with .net and data binding. Here is the code that i tried but it only retrieves the car model for the specified id. If I delete the id it doesn't work. Also it writes the car model in the listbox vertically such as: B M W CODE: Imports System.Data Imports ADODB Imports System.Data.OleDb Public Class listboxADO Inherits System.Web.UI...

Web resources about - ADOConnection.Provider = ? - embarcadero.delphi.ado

var Item1 : TTreeViewItem; Item2 : TTreeViewItem; begin Item1 := TTreeView - Pastebin.com
var Item1 : TTreeViewItem; Item2 : TTreeViewItem;begin Item1 := TTreeViewItem.Create(Self); Item1.Text := 'My First Node'; Item1.Parent := TreeView1; ...

bitweaver - White Screen of Death
Click here to log a bug , if this appears to be an error with the application. Go here to begin the installation process , if you haven't done ...

Resources last updated: 11/28/2015 3:52:41 PM