ACCESS中自定義鏈接后端數(shù)據(jù)庫

字號:

代碼很簡單的,考試大提示: 這里的例子是從文本框里輸入新的數(shù)據(jù)庫路徑,然后更新鏈接。參考一下。
    Private Sub Command0_Click()
    On Error GoTo Err_Command0_Click
    Dim cat As ADOX.Catalog
    Dim tdf As ADOX.Table
    Me.txtDBnewNAME.SetFocus
    Set cat = New ADOX.Catalog
    Set cat.ActiveConnection = CurrentProject.Connection
    Set tdf = cat.Tables(\"mytable\")
    tdf.Properties(\"jet oledb:link datasource\") = Me.txtDBnewNAME.Text
    Exit_Command0_Click:
    Exit Sub
    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click
    End Sub