office交流網(wǎng)--QQ交流群號(hào)及微信交流群

Access培訓(xùn)群:792054000         Excel免費(fèi)交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

微信交流群(請(qǐng)用微信掃碼)

        

Access DAO與ADO創(chuàng)建索引時(shí)一些屬性的區(qū)別及對(duì)應(yīng)關(guān)系

2002-06-16 17:48:00
tmtony-Office交流網(wǎng)
原創(chuàng)
5361
DAO與ADO創(chuàng)建索引時(shí)一些屬性的區(qū)別及對(duì)應(yīng)關(guān)系
DAO:
Required = True
IgnoreNulls = True Or False
ADO:
adIndexNullsDisallow 空值是不允許的, 索引項(xiàng)沒有加上

DAO:
Required = False
IgnoreNulls = True
ADO:
adIndexNullsIgnore 索引字段允許空值, 但索引項(xiàng)不添加

DAO:
Required = False
IgnoreNulls = False
ADO:
adIndexNullsAllow 索引字段允許空值,添加索引項(xiàng)

zhuyiwen
好!

esmile
難得出現(xiàn)有DAO與ADO有針對(duì)性比較的貼子,希望多多……

ADAM
這樣啊,我這里也有,貼一個(gè)吧:

DAO
Sub DAOCreatePrimaryKey()

    Dim db      As DAO.Database
    Dim tbl     As DAO.TableDef
    Dim idx     As DAO.Index
    
    'Open the database
    Set db = DBEngine.OpenDatabase("C:\nwind.mdb")
    
    Set tbl = db.TableDefs("Contacts")
    
    ' Create the Primary Key and append table columns to it.
    Set idx = tbl.CreateIndex("PrimaryKey")
    idx.Primary = True
    idx.Fields.Append idx.CreateField("ContactId")
    
    ' Append the Index object to the Indexes collection of the TableDef.
    tbl.Indexes.Append idx

    db.Close

End Sub

ADOX
Sub ADOCreatePrimaryKey()

    Dim cat     As New ADOX.Catalog
    Dim tbl     As ADOX.Table
    Dim pk      As New ADOX.Key
    
    ' Open the catalog
    cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\nwind.mdb;"

    Set tbl = cat.Tables("Contacts")
        
    ' Create the Primary Key and append table columns to it.
    pk.Name = "PrimaryKey"
    pk.Type = adKeyPrimary
    pk.Columns.Append "ContactId"
    
    ' Append the Key object to the Keys collection of Table
    tbl.Keys.Append pk
    
    Set cat = Nothing
    
End Sub

分享
文章分類
聯(lián)系我們
聯(lián)系人: 王先生
Email: 18449932@qq.com
QQ: 18449932
微博: officecn01
移動(dòng)訪問