Hi,

Please let me know if anybody knows that how to get schema information of a table (e.g. columns name,data type, key columns.. etc) using c++.I don't want to use system tables query and things like that.I was searching on the net and found CIndexes and other classes but not found any solution that i could run on my pc and test it.
Waiting for reply.

Thanks,

Asif

Recommended Answers

All 4 Replies

>>I don't want to use system tables query and things like that.

Things like what? If you use ODBC the result set will contain the table information for the columns returned. I'm sure you could also query the system tables for the info using ODBC. More information might be found in the DaniWeb Database board

>>I don't want to use system tables query and things like that.

Things like what? If you use ODBC the result set will contain the table information for the columns returned. I'm sure you could also query the system tables for the info using ODBC. More information might be found in the DaniWeb Database board

Hi,
Thanks for responding.I wanted to get information of table columns and key columns from the database.The table name will be entered by user at run time.I know that there are some queries that could be used for retrieving column name and key information but i can't use those that because i have to retrieve same information from different databases using same code.I am using Pervasive and sql server DBs.Please reply if you can help me.

Thanks,
Asif

hi Asif,

if you don't like to query system tables, what really differs from database to database, you can use standard ODBC. ODBC has some functions to query system tables information independently from a specific database system. For example these ODBC functions are usually supported by odbc drivers

SQLColumnPrivileges() - Get column privileges
SQLColumns() - Get column information
SQLForeignKeys() - Get a list of foreign key columns
SQLPrimaryKeys() - Get primary key columns of a table
SQLProcedureColumns() - Get procedure input/output parameter information
SQLProcedures() - Get a list of procedure names
SQLSpecialColumns() - Get special (row identifier) columns
SQLStatistics() - Get index and statistics information for a base table
SQLTablePrivileges() - Get table privileges
SQLTables() - Get table information


You may search the net, for example MSDN-ODBC, IBM-ODBC etc.


krs,
tesu

If you use ODBC it won't matter what databases you use as long as the databases support ODBC, and nearly all of them do.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.