开发者

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

开发者 https://www.devze.com 2023-01-25 03:36 出处:网络
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 t

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开发者_如何学Go-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!?


exec sp_help '<tablename>'

or

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


You can use GetSchema on the Connection object.

0

精彩评论

暂无评论...
验证码 换一张
取 消