如何从vb.net中的sql数据库中获取所有表 [英] How do I fetch all tables from sql database in vb.net

查看:187
本文介绍了如何从vb.net中的sql数据库中获取所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用下面显示的代码将我的所有数据库提取到组合框中。我现在的挑战是获取所选组合框中嵌入的所有表(数据库名称),并在名为cmbDataBaseTable的组合框中填充它们,并使用结果获取所选表的主键表,这些表稍后保存在另一个数据库中。



I have make use of the code shown below to fetch all my database into combo box. My challenge now is to fetch out all the tables embedded in the selected combo box (Database name)and populate them in a combo box named cmbDataBaseTable and use the result to fetch the primary key table of the selected table which are later saved in another database.

Private Sub frmVPraiseapp_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim server As New Microsoft.SqlServer.Management.Smo.Server("DEVELOPER\SQLEXPRESS")
        For Each db As Microsoft.SqlServer.Management.Smo.Database In server.Databases
            cmbcompany.Items.Add(db.Name)
        Next
    End Sub

推荐答案

每个数据库的SELECT [name] FROM sys.tables
SELECT [name] FROM sys.tables for each database


这是我不久前一起入侵的东西。它是C#,但转换为VB.Net应该是直截了当的。



YADDU。又一个(MS-SQL)数据库文档实用程序 [ ^ ]



如果您删除了点头的Web UI以及检索扩展属性的内容剩下几个相当简单的查询,可以用来用信息填充数据视图。你是在追求。
Here's something I hacked together a while ago. It's C#, but translation to VB.Net should be straight-forward.

YADDU. Yet Another (MS-SQL) Database Documentation Utility[^]

If you strip out the noddy web UI and the stuff that retrieves extended properties you're left with a couple of fairly simple queries that can be used to fill dataviews with the info. you're after.


这篇关于如何从vb.net中的sql数据库中获取所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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