Listing Data Types

The ListDataTypes procedure in Hands-On 11-14 uses the adSchemaProvider-Types parameter of the ADO Connection object's OpenSchema method to list the data types supported by the Microsoft Jet OLE DB 4.0 provider.

©Hands-On 11-14: Listing Data Types

1. In the Visual Basic Editor window, choose Insert | Module.

2. In the module's Code window, type the ListDataTypes procedure shown below.

3. Choose Run | Run Sub/UserForm to execute the procedure.

Sub ListDataTypes()

Dim conn As ADODB.Connection Dim rst As ADODB.Recordset

Set conn=New ADODB.Connection conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" _ & "Data Source=" & CurrentProject.Path & _ "\Northwind.mdb" Set rst=conn.OpenSchema(adSchemaProviderTypes) Do Until rst.EOF

Debug.Print rst!Type_Name & vbTab _

& "Size: " & rst!Column_Size rst.MoveNext Loop

Creating and Manipulating Databases with ADO

rst.Close conn.Close Set rst = Nothing Set conn = Nothing End Sub

0 0

Post a comment