可以在getCollect之前,先看看Field的type是什么。 Public Sub TypeX() Dim rstEmployees As ADODB.Recordset Dim fldLoop As ADODB.Field Dim strCnn As String ' Open recordset with data from Employees table. strCnn = "Provider=sqloledb;" & _ "Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; " Set rstEmployees = New ADODB.Recordset rstEmployees.Open "employee", strCnn, , , adCmdTable Debug.Print "Fields in Employees Table:" & vbCr ' Enumerate Fields collection of Employees table. For Each fldLoop In rstEmployees.Fields Debug.Print " Name: " & fldLoop.Name & vbCr & _ " Type: " & FieldType(fldLoop.Type) & vbCr Next fldLoopEnd SubPublic Function FieldType(intType As Integer) As String Select Case intType Case adChar FieldType = "adChar" Case adVarChar FieldType = "adVarChar" Case adSmallInt FieldType = "adSmallInt" Case adUnsignedTinyInt FieldType = "adUnsignedTinyInt" Case adDBTimeStamp FieldType = "adDBTimeStamp" End SelectEnd Function 这个虽然是VB的例子,但应该也能有启发作用
Public Sub TypeX() Dim rstEmployees As ADODB.Recordset
Dim fldLoop As ADODB.Field
Dim strCnn As String ' Open recordset with data from Employees table.
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "
Set rstEmployees = New ADODB.Recordset
rstEmployees.Open "employee", strCnn, , , adCmdTable Debug.Print "Fields in Employees Table:" & vbCr ' Enumerate Fields collection of Employees table.
For Each fldLoop In rstEmployees.Fields
Debug.Print " Name: " & fldLoop.Name & vbCr & _
" Type: " & FieldType(fldLoop.Type) & vbCr
Next fldLoopEnd SubPublic Function FieldType(intType As Integer) As String Select Case intType
Case adChar
FieldType = "adChar"
Case adVarChar
FieldType = "adVarChar"
Case adSmallInt
FieldType = "adSmallInt"
Case adUnsignedTinyInt
FieldType = "adUnsignedTinyInt"
Case adDBTimeStamp
FieldType = "adDBTimeStamp"
End SelectEnd Function
这个虽然是VB的例子,但应该也能有启发作用