Tech Off Thread

2 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Easy way to convert GetSchema DataTable into a real DataTable?

Back to Forum: Tech Off
  • User profile image
    vulgrin

    I'm playing around with "DB Reflection" with the DBConnection.GetSchema method.  Nice and easy to use, but the information for the schema comes back as a big ole table that I have to parse.  (in my case, I'm getting the columns for a particular table)

    Is there an easy way to "convert" this GetSchema result table into a DataTable schema?  That is to say a DataTable with Columns that have all of the properties brought back from the GetSchema.  This way I can query my column properties (such as DataColumn.Autoincrement) in a more logical way.

    OR, is anyone aware of any code snippets out there that will do the conversion for me, that I can copy and paste in.  I've been googling, but can't find anything useful.

    OR, is there an easy way to get at this information that doesn't use GetSchema?  I tried a "SELECT TOP 1 * from MyTable" into a DataSet, but the column properties like Autoincrement and AllowNull weren't filled...

    If there ISNT a way to do this, then I hope someone at MS takes it as a suggestion for the next ADO.NET point release or something.  Just a simple method added to Connection like  DataTable SqlConnection.GetTableSchema or something to do the conversion for us.

    Its late.  I hope this blathering makes sense.

  • User profile image
    vulgrin

    Wow.  Is the question that bad, or does no one actually use GetSchema?

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.