|
Sub Main()
Dim Cnxn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim fld As ADODB.Field
Dim strCnxn As String
Dim strSQL As String
Dim FieldType As String
Set Cnxn = New ADODB.Connection
strCnxn = "rovider='sqloledb';Data Source='MySqlServer';" & _
"Initial Catalog='Pubs';Integrated Security='SSPI';"
Cnxn.Open strCnxn
Set rst = New ADODB.Recordset
strSQL = "employee"
rst.Open strSQL, Cnxn, , , adCmdTable
Debug.Print "Fields in Employees Table:" & vbCr
For Each fld In rstEmployees.Fields
Select Case fld.Type
Case adChar
FieldType = "adChar"
Case adVarChar
FieldType = "adVarChar"
Case adSmallInt
FieldType = "adSmallInt"
Case adUnsignedTinyInt
FieldType = "adUnsignedTinyInt"
Case adDBTimeStamp
FieldType = "adDBTimeStamp"
End Select
Debug.Print " Name: " & fld.Name & vbCr & " Type: " & FieldType & vbCr
Next
rstEmployees.Close
Cnxn.Close
Set rstEmployees = Nothing
Set Cnxn = Nothing
End Sub
|
|