随便一写,这个逻辑应该可以 for i=0 to rs.fields.count-1 if rs.fields.name=你要找到的字段名 then exit for end if next if i<=rs.fields.count-1 then 存在 else 不存在 endif
楼上的办法,for循环就可以了
For i = 0 To rs.RecordCount - 1 Print rs.Fields(i).Name Next
呵呵,我上面错了 For i = 0 To rs.Fields.Count - 1 Print rs.Fields(i).Name Next
写个函数判断. Private Function ExistFields(rs As ADODB.Recordset, FieldName As String) As Boolean Dim i As Integer For i = 0 To rs.Fields.Count - 1 If LCase(rs.Fields(i).Name) = LCase(FieldName) Then ExistFields = True Exit For End If Next i End Function
我也写错了,下面这样才对,呵呵for i=0 to rs.fields.count-1 if rs.fields(i).name=你要找到的字段名 then exit for end if next if i<=rs.fields.count-1 then 存在 else 不存在 endif
for i=0 to rs.fields.count-1
if rs.fields.name=你要找到的字段名 then
exit for
end if
next
if i<=rs.fields.count-1 then
存在
else
不存在
endif
For i = 0 To rs.RecordCount - 1
Print rs.Fields(i).Name
Next
For i = 0 To rs.Fields.Count - 1
Print rs.Fields(i).Name
Next
Private Function ExistFields(rs As ADODB.Recordset, FieldName As String) As Boolean
Dim i As Integer
For i = 0 To rs.Fields.Count - 1
If LCase(rs.Fields(i).Name) = LCase(FieldName) Then
ExistFields = True
Exit For
End If
Next i
End Function
if rs.fields(i).name=你要找到的字段名 then
exit for
end if
next
if i<=rs.fields.count-1 then
存在
else
不存在
endif