在ADO中,我可以使用Field中的Name获取字段名称、Type获取类型找了好久就是没有 怎样判断该字段是否是主建、是否是自增列(自动编号)、是否可以获得?

解决方案 »

  1.   

    Adodc1.RecrodSet.Field(i).Properties(I).ValueI:1.字段
      2.表
      3.数据库
      5.主键
      

  2.   

    谢谢!Adodc1.RecrodSet.Field(i).Properties(5).Value
    不过 主建都是False,我明明设置了主建的
      

  3.   

    判断是否PRIMARYINDEX要通过ADOX获得TABLE对象,再由TABLE对象获得INDEXS集合,再循环判断某个INDEX是否你说的主键。
      

  4.   

    to:province_(雍昊) 
    谢谢!具体怎么做!
      

  5.   

    引用 microsoft ado ext. xxx for  DDL and Security.......
      

  6.   

    How To Use ADOX to Determine If a Primary Key Exists on a Table
    http://support.microsoft.com/kb/q258013/
      

  7.   

    使用ADOX动态创建数据库,表,字段.
    http://chenoe.com/blog/blogview.asp?logID=1912
      

  8.   

    主建倒是解决了!但是自动编号还是不行。
    Idx.Properties("Autoincrement")
    提示说:在对应的集合中,未找到项目
      

  9.   

    Dim cn As ADODB.Connection
      Dim cat As ADOX.Catalog
      Set cn = New ADODB.Connection
      With cn
        .Provider = "SQLOLEDB"
        .ConnectionString = "Data Source=(local);Initial Catalog=Northwind;User ID=<UID>;Password=<strong password>;"
        .Open
      End With
      Set cat = New ADOX.Catalog
      Set cat.ActiveConnection = cn
      Debug.Print cat.Tables("Customers").Columns("CustomerID").Properties("Autoincrement").Value
      

  10.   

    谢谢!jiangsheng(蒋晟.Net[MVP]) 
    怎么还是不行啊!提示错误;
    对象或提供程序不能执行所需的操作
      

  11.   

    调式的时候
    cat.tables("Customers").Columns("CustomerID").Properties
    集合里面的项目都是 <对象或提供程序不能执行所需的操作>在网上找了N 久代码都是这样写的,我怎么就不能用了,真是郁闷啊!