请问如何用ado取到数据表的结构(字段名)?

解决方案 »

  1.   

    for i =0 to rs.Fields.count -1
        msgbox rs.fields(i).name
    next i
      

  2.   

    Dim Conn3 As New ADODB.Connection
    Dim Rst3 As New ADODB.Recordset
    Dim StrConn As String
    Dim SQLConn As String'以下是一个连DBF的例子
    StrConn = "Provider=MSDASQL.1;Driver=Microsoft Visual Foxpro _
               Driver;SourceDB=" & DBFPath & ";SourceType=DBF"
    Conn3.CursorLocation = adUseClient
    Conn3.Open StrConn
    SQLConn = "select * from " & 表名
    Rst3.Open SQLConn, Conn3, adOpenStatic, adLockOptimisticdim FieldValue as stringfieldvalue=rst3!姓名
      

  3.   

    如果是SQL SERVER
    就在SYSOBJECT表中取
      

  4.   

    对不起,看错了。是rs.fields(i).name
      

  5.   

    http://www.csdn.net/develop/read_article.asp?id=15422
                   For I = 0 To Rs_Colums.Fields.Count - 1   ' 循环所有列
                        Debug.Print Rs_Colums.Fields(I).Name   '字段名
                        Debug.Print FieldType(Rs_Colums.Fields(I).Type)  '字段类型
                        Debug.Print Rs_Colums.Fields(I).DefinedSize  '宽度
                    Next