Getting the schema for a table

前端 未结 3 1401
死守一世寂寞
死守一世寂寞 2020-12-10 07:53

Given an SQLConnection object how can you get a schema for a single table?

I was trying this the other day and I seemed to be able to get the schema from a DataSet w

3条回答
  •  [愿得一人]
    2020-12-10 08:34

    I think accessing the schema from the query (via GetSchemaTable) is the only way to do it. You can run a query which returns no rows (select * from table where 1=2) if the schema is all you're interested in.

    You should use the KeyInfo CommandBehaviour to execute the source query, as otherwise not all the information returned is guaranteed to be accurate

    Command.ExecuteReader(CommandBehavior.KeyInfo)
    

提交回复
热议问题