設(shè)為首頁收藏本站Access中國

Office中國論壇/Access中國論壇

 找回密碼
 注冊

QQ登錄

只需一步,快速開始

返回列表 發(fā)新帖
查看: 4089|回復(fù): 3
打印 上一主題 下一主題

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

[復(fù)制鏈接]

點(diǎn)擊這里給我發(fā)消息

跳轉(zhuǎn)到指定樓層
1#
發(fā)表于 2002-6-16 17:48:00 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
DAO與ADO創(chuàng)建索引時一些屬性的區(qū)別及對應(yīng)關(guān)系
DAO:
Required = True
IgnoreNulls = True Or False
ADO:
adIndexNullsDisallow 空值是不允許的, 索引項沒有加上

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

DAO:
Required = False
IgnoreNulls = False
ADO:
adIndexNullsAllow 索引字段允許空值,添加索引項
(DAO_鏈接表_ODBC-相關(guān)文章技巧鏈接):
Access DAO與ADO創(chuàng)建索引時一些屬性的區(qū)別及對應(yīng)關(guān)系

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享分享 分享淘帖 訂閱訂閱

點(diǎn)擊這里給我發(fā)消息

2#
發(fā)表于 2003-10-17 19:35:00 | 只看該作者
好!
3#
發(fā)表于 2003-10-17 21:50:00 | 只看該作者
提示: 作者被禁止或刪除 內(nèi)容自動屏蔽
4#
發(fā)表于 2003-10-17 21:54:00 | 只看該作者
這樣啊,我這里也有,貼一個吧:

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("rimaryKey")
    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 = "rovider=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 = "rimaryKey"
    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
您需要登錄后才可以回帖 登錄 | 注冊

本版積分規(guī)則

QQ|站長郵箱|小黑屋|手機(jī)版|Office中國/Access中國 ( 粵ICP備10043721號-1 )  

GMT+8, 2024-10-23 08:26 , Processed in 0.162381 second(s), 27 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回復(fù) 返回頂部 返回列表