Click here to Skip to main content
15,885,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

VB
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
Posted
Comments
Simeon Abiodun 20-Aug-14 10:41am    
Yeah! thanks, can you please shed more light on how I can implement it from Vb.net code. I mean from the event handler selected index change of the combo box that fetch out all the database name.

SELECT [name] FROM sys.tables for each database
 
Share this answer
 
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.
 
Share this answer
 
Comments
Simeon Abiodun 21-Aug-14 6:56am    
Thanks; the work is done. Kudos to CodeProject comunity

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900