(c) 2002 Visual Studio Magazine 
Fawcette Technical Publications

Issue: September 2002
Section: Database Design
Author: Dino Esposito


VB.NET, SQL Server		Get a Particular SQL Server Catalog's Schema Information.
Listing 1	A built-in table called INFORMATION_SCHEMA contains information about the schema of all the tables that belong to the database the application is connected to. 

Function GetSqlSchemaInfo() As DataSet
	Dim s As String
	s = ConnectionString
	Dim conn As SqlConnection
	conn = New SqlConnection(s)

	Dim c As String
	c = "SELECT "
	c += "COLUMN_NAME, "
	c += "ORDINAL_POSITION, "
	c += "COLUMN_DEFAULT, "
	c += "IS_NULLABLE, "
	c += "DATA_TYPE FROM "
	c += "MyData.INFORMATION_SCHEMA.COLUMNS "
	c += "WHERE TABLE_NAME = 'MyClients'"

	Dim cmd As SqlCommand
	cmd = New SqlCommand()
	cmd.Connection = conn
	cmd.CommandText = c

	Dim da As SqlDataAdapter
	da = New SqlDataAdapter()
	da.SelectCommand = cmd

	Dim ds As DataSet
	ds = New DataSet()
	da.Fill(ds, "Schema")
	Return ds
End Function

