|
|
Title | Use ADO to display SQL Server tables and records in a TreeView control |
Keywords | ADO, SQL Server, database |
Categories | Database |
|
|
This example uses the ADODB.Connection object to execute SQL statements that fetch information describing
the database structure. The following table shows the SQL statements the program uses to learn about
different parts of the database.
Information | SQL Statement |
Databases on Server |
SELECT Name
FROM sysdatabases
WHERE Name NOT IN ('Master','Tempdb','Model','msdb') |
Tables in Databases |
SELECT table_name
FROM INFORMATION_SCHEMA.TABLES
WHERE table_type = 'base table'
ORDER BY table_name
FROM sysdatabases
WHERE Name NOT IN ('Master','Tempdb','Model','msdb') |
Columns in a Table |
SELECT top 1 *
FROM <table name> |
Records in a Table |
SELECT top <number>
FROM <table name>
WHERE <where condition> |
Thanks to Roberts Bill.
Check out my book Visual Basic.NET Database Programming
for lots more information on exploring and manipulating SQL Server, MSDE, Access,
and other databases using Visual Basic .NET.
|
|
|
|
|
|
|
|