Wrox Home  
Search P2P Archive for: Go

  Return to Index  

activex_data_objects thread: How to retrieve the TABLE NAME of the database I am reading?


Message #1 by "yinmos" <yinmos@y...> on Mon, 24 Sep 2001 19:02:45
I am writing a program that will read a unknown database of unknown Table 

Name. Is there any possible way that i can retrieve all the table names in 

the database? Fields name is need also.

Message #2 by "Tomm Matthis" <matthis@b...> on Tue, 25 Sep 2001 08:29:32 -0400
Look into using ADOX ... it will do what you need.



-- Tomm



> -----Original Message-----

> From: yinmos [mailto:yinmos@y...]

> Sent: Monday, September 24, 2001 7:03 PM

> To: ActiveX_Data_Objects

> Subject: [activex_data_objects] How to retrieve the TABLE NAME of the

> database I am reading?

>

>

> I am writing a program that will read a unknown database of unknown Table

> Name. Is there any possible way that i can retrieve all the table

> names in the database? Fields name is need also.
Message #3 by Thomas Bellavia <TBellavia@V...> on Tue, 25 Sep 2001 11:03:32 -0400
Here is just a snippet of code to peruse...



        // Instantiate connection interface object

        SAFE_CALL(pConnection.CreateInstance(__uuidof(Connection)));



        // Instantiate recordset interface object

        SAFE_CALL(pRstSchema.CreateInstance(__uuidof(Recordset)));



        // Clear errors collection for connection object

        SAFE_CALL(pConnection->Errors->Clear());



        // Open database schema to establish content before accessing

individual tables and rows

        TRACE0((LPSTR)bstrconnectstring);

        TRACE0("\n");



 

SAFE_CALL(pConnection->Open(bstrconnectstring,"","",adConnectUnspecified));



        // Open schema to query for table names

        pRstSchema = pConnection->OpenSchema(adSchemaTables);



        // Retreive MDAC Version Information for registry

        variant_t vtVersion = (bstr_t)pConnection->Version;



        bstr_t bstrProviderVersion = bstr_t(vtVersion);



        cProviderVersion = (LPCWSTR)bstrProviderVersion;



        table_count = 0;



        // Get names of tables...

        while(!(pRstSchema->EndOfFile))

        {

            // Get table name

            bstrTablename 

(bstr_t(pRstSchema->Fields->GetItem("TABLE_NAME")->Value));



            // Get table type

            bstrTabletype 

(bstr_t(pRstSchema->Fields->GetItem("TABLE_TYPE")->Value));



            // Only store "TABLE" fields for data extraction

            if(_stricmp(_strupr((LPSTR)bstrTabletype),"TABLE") == 0)



                Do something...



            }   // if(_stricmp(_strupr((LPSTR)bstrTabletype),"TABLE") == 0)



            // Advance to next field

            if(!(pRstSchema->EndOfFile))

                pRstSchema->MoveNext();

        };/*while(){}*/

etc...



-----Original Message-----

From: yinmos [mailto:yinmos@y...]

Sent: Monday, September 24, 2001 3:03 PM

To: ActiveX_Data_Objects

Subject: [activex_data_objects] How to retrieve the TABLE NAME of the

database I am reading?





I am writing a program that will read a unknown database of unknown Table 

Name. Is there any possible way that i can retrieve all the table names in 

the database? Fields name is need also.
Message #4 by "Belina, Jeff" <JBELINA@t...> on Thu, 27 Sep 2001 15:53:06 -0400
Here's a recent article that goes along with Thomas Bellavia's code

snippets...



VB Q&A - Much "ADO" about field properties 

http://www.techrepublic.com/article.jhtml?id=r00820010813adm01.htm&fromtm=e0

46



Thanks,

Jeff M. Belina

MCP, MCSD, MCDBA, MCSE, MSS, i-Net+

Database Administrator, DDBA

Moderator of the MCDBA Discussion List

http://ls.swynk.com





-----Original Message-----



> From: yinmos [mailto:yinmos@y...]

> Sent: Monday, September 24, 2001 7:03 PM

> To: ActiveX_Data_Objects

> Subject: [activex_data_objects] How to retrieve the TABLE NAME of the

> database I am reading?

>

>

> I am writing a program that will read a unknown database of unknown Table

> Name. Is there any possible way that i can retrieve all the table

> names in the database? Fields name is need also.


  Return to Index