Microsoft ActiveX Data ObjectsMicrosoft ActiveX Data Objects*
*Contents  *Index  *Topic Contents

OpenSchema Method Example

This example uses the OpenSchema method to display the name and type of each table in the Pubs database.

Public Sub OpenSchemaX()

	Dim cnn1 As ADODB.Connection
	Dim rstSchema As ADODB.Recordset
	Dim strCnn As String
		
	Set cnn1 = New ADODB.Connection
	strCnn = "driver={SQL Server};server=srv;" & _
		"uid=sa;pwd=;database=pubs"
	cnn1.Open strCnn
		
	Set rstSchema = cnn1.OpenSchema(adSchemaTables)
	
	Do Until rstSchema.EOF
		Debug.Print "Table name: " & _
			rstSchema!TABLE_NAME & vbCr & _
			"Table type: " & rstSchema!TABLE_TYPE & vbCr
		rstSchema.MoveNext
	Loop
	rstSchema.Close
	
	cnn1.Close
	
End Sub

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.