自定义链接后端数据库

发表于:2007-07-02来源:作者:点击数: 标签:
代码很简单的,我这里的例子是从文本框里输入新的 数据库 路径,然后更新链接。你参考一下,再改。 Private Sub Command0_Click() On Error GoTo Err_Command0_Click Dim cat As ADOX.Catalog Dim td f As ADOX.Table Me.txtDBnewNAME.SetFocus Set cat = Ne

代码很简单的,我这里的例子是从文本框里输入新的数据库路径,然后更新链接。你参考一下,再改。
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

原文转自:http://www.ltesting.net