I am making a DAL template with C# and I am wondering what is the most efficient way to access schema information with ODBC and OleDB. I need the columns, column types, and primary key information.
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For OleDb, there is an OleDbConnection.GetoleDbSchemaTable() method. I’ve used it with Access.
I have an example in this code on GitHub: SchemaValidator.cs
There should be a .Schema() method on OdbcConnection too IIRC.
I have noticed that the actual returned values may vary by database, so you’ll want to do a fair amount of checking and debugging to see what he returned values may be.