如何读取.NET SQL Server架构信息? [英] How to read SQL server schema info in .net?

查看:170
本文介绍了如何读取.NET SQL Server架构信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能知道在C#中的数据库表的列表。

How can I know in C# the list of Tables in database.

列各表的列表具有规格齐全像列一个是ID,并具有INT(50)的数据类型,等等

The list of columns each tables has with complete specification like column one is Id and it has data type of int(50), etc

推荐答案

使用的getSchema 的<一个方法href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.aspx">SqlConnection类:

DataTable t = _conn.GetSchema("Tables");

有关详细信息请阅读MSDN文章的 检索数据库架构信息(ADO.NET) 的。请注意,这将让你无需编写或直接传递/执行任意SQL的结果。

For more info read the MSDN article Retrieving Database Schema Information (ADO.NET). Note that this will get you the results without having to write or directly pass/execute any SQL.

这篇关于如何读取.NET SQL Server架构信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆