久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

如何使用 ADOX 通過(guò)主鍵創(chuàng)建表

 zele 2011-03-17

創(chuàng)建示例應(yīng)用程序的步驟

  1. 在 Microsoft Visual Basic 5.0 或 6.0 中創(chuàng)建一個(gè)新的標(biāo)準(zhǔn) EXE 項(xiàng)目。默認(rèn)情況下創(chuàng)建 Form1,。
  2. 項(xiàng)目 菜單上選擇要添加以下類型庫(kù)的 引用
    Microsoft ActiveX 數(shù)據(jù)對(duì)象 2.1 庫(kù)
    Microsoft ADO 分機(jī) 2.1 DDL 和安全
  3. 在 Form1 中添加兩個(gè) 命令 按鈕 (Command1 和 Command2) 和下面的代碼:
    Option Explicit

    Private Sub Command1_Click()
    '
    ' This code adds a single-field Primary key
    '
    Dim Cn As ADODB.Connection, Cat As ADOX.Catalog, objTable As ADOX.Table

    Set Cn = New ADODB.Connection
    Set Cat = New ADOX.Catalog
    Set objTable = New ADOX.Table

    'Open the connection
    Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=biblio.mdb"

    'Open the Catalog
    Set Cat.ActiveConnection = Cn

    'Create the table
    objTable.Name = "Test_Table"

    'Create and Append a new field to the "Test_Table" Columns Collection
    objTable.Columns.Append "PrimaryKey_Field", adInteger

    'Create and Append a new key. Note that we are merely passing
    'the "PimaryKey_Field" column as the source of the primary key. This
    'new Key will be Appended to the Keys Collection of "Test_Table"
    objTable.Keys.Append "PrimaryKey", adKeyPrimary, "PrimaryKey_Field"

    'Append the newly created table to the Tables Collection
    Cat.Tables.Append objTable

    ' clean up objects
    Set objKey = Nothing
    Set objTable = Nothing
    Set Cat = Nothing
    Cn.Close
    Set Cn = Nothing
    End Sub

    Private Sub Command2_Click()
    '
    ' This code adds a multi-field Primary Key
    '
    Dim Cn As ADODB.Connection, Cat As ADOX.Catalog
    Dim objTable As ADOX.Table, objKey As ADOX.Key

    Set Cn = New ADODB.Connection
    Set Cat = New ADOX.Catalog
    Set objTable = New ADOX.Table
    Set objKey = New ADOX.Key

    Cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=biblio.mdb"
    Set Cat.ActiveConnection = Cn
    objTable.Name = "Test_Table2"

    objTable.Columns.Append "PrimaryKey_Field1", adInteger
    objTable.Columns.Append "PrimaryKey_Field2", adInteger

    objKey.Name = "PrimaryKey"
    objKey.Type = adKeyPrimary
    objKey.Columns.Append "PrimaryKey_Field1"
    objKey.Columns.Append "PrimaryKey_Field2"

    objTable.Keys.Append objKey

    Cat.Tables.Append objTable

    ' clean up objects
    Set objKey = Nothing
    Set objTable = Nothing
    Set Cat = Nothing
    Cn.Close
    Set Cn = Nothing
    End Sub
    : 您可能需要調(diào)整指向有效的 Jet 數(shù)據(jù)庫(kù)連接字符串,。
  4. 運(yùn)行該應(yīng)用程序,,然后單擊 命令 按鈕。您可以檢查 Test_Table 和 TestTable2 Microsoft Access 97、 Microsoft Access 2000,,或 Visual Basic 可視化數(shù)據(jù)管理器加載項(xiàng)中的對(duì)表定義,。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多