Is there no built in way to get a table's schema in ADO.NET?

若如初见. 提交于 2019-12-24 01:57:41

问题


I want to get a table's schema in order. This question and its answer is exactly my question, and what I want to do. However it feels (to me) pretty hackish, and being two years old now I was hoping that the answer was out-of-date. Is there truly still no way to get a table's schema in its native order? (e.g. ADOX's OpenSchema(adSchemaTables...))?

Subjective side-question: is this not a huge gaping hole in ADO.NET in general!?


回答1:


exec sp_help '<tablename>'

or

select * from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = '<tablename>' order by ORDINAL_POSITION



回答2:


You can use GetSchema on the Connection object.



来源:https://stackoverflow.com/questions/4155993/is-there-no-built-in-way-to-get-a-tables-schema-in-ado-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!