» 网友学堂 » ACCESS教程 » 自定义链接后端数据库
自定义链接后端数据库
作者:问天 发表时间:2007-2-20 11:47 阅读:352次 在百度搜索相关内容

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

Exit_Command0_Click:
Exit Sub
[color=#FFFFFF'][/color]

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub

#Advertisement