Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi,

 

there is a method (DLL, native class...), using c#, to get list (and properties) of all DATA Providers installed on the running operating system ?

I want develop a small DTS in wich you can select source and target database using any provider !

 

Thanks in advance

Posted
Hi,

 

there is a method (DLL, native class...), using c#, to get list (and properties) of all DATA Providers installed on the running operating system ?

I want develop a small DTS in wich you can select source and target database using any provider !

 

Thanks in advance

 

don't know if this is what you want but...

you could use the Data Links dialog box (same one used by VS)

 

1. Add references to the librarys:

Microsoft OLE DB Service Component 1.0

Microsoft ActiveX Data Objects 2.7

 

2. Launch the dialog and use the returned connection string

MSDAC.DataLinks d = new MSDAC.DataLinksClass();
ADODB.Connection c = new ADODB.ConnectionClass();
d.PromptEdit( ref c );
Console.WriteLine( c.ConnectionString );

of course these are OLE DB connection strings.

IN PARVUM MULTUM
Posted
Hi,

 

there is a method (DLL, native class...), using c#, to get list (and properties) of all DATA Providers installed on the running operating system ?

I want develop a small DTS in wich you can select source and target database using any provider !

 

Thanks in advance

I think this will work (REQUIRES VC7) . . .

 

  1. create a C++ Class Library Project, Call it OLEDBSources
  2. Add a reference to the ADODB Interop assembly
  3. replace the text in the OLEDBSources.h file with this text:
    // OLEDBSources.h
    #pragma once
    using namespace System;
    namespace OLEDBSources
    {
      public __gc class RecordsetClass
      {
      public:
    	 static ADODB::Recordset* GetRecordset(void);
      };
    }
    


     

  4. replace the text in the OLEDBSources.cpp file with this text:
     // This is the main DLL file.
    #include ".\stdafx.h"
    #include ".\oledbsources.h"
    #include <oledb.h>
    #include <msdaguid.h>
    #include "OLEDBSources.h"
    ADODB::Recordset* OLEDBSources::RecordsetClass::GetRecordset(void)
    {
      ADODB::Recordset* SourcesRecordset = new ADODB::RecordsetClass();
      ADODB::ADORecordsetConstruction *RSCon = dynamic_cast<ADODB::ADORecordsetConstruction *>(SourcesRecordset) ; 
      ISourcesRowset *SourcesRowset; 
      CoCreateInstance(CLSID_OLEDB_ENUMERATOR, NULL, CLSCTX_ALL, IID_ISourcesRowset,(void **) &SourcesRowset);  
      Object*			  pIRowset;
      DBPROPSET		 rgPropSets[1];
      SourcesRowset -> GetSourcesRowset (NULL, IID_IRowset, 1, rgPropSets, (IUnknown**) &pIRowset);
      RSCon -> Rowset =  pIRowset;
      return SourcesRecordset;
    }
    


     

NOTE. . . I HAD TO CHANGE A LINE IN THE OCIDL.H!!! Specifically:

in the typedef of tagQACONTAINER, I had to change

 

IServiceProvider *pServiceProvider;

to

LPSERVICEPROVIDER *pServiceProvider;

to overcome an ambiguous reference. . . I am probably doing something wrong in my project file.

Joe Mamma

Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized.

Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...