自定义链接后端数据库

80酷酷网    80kuku.com

  

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















分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: