I am trying to write a VB6 application to relink Access97 linked tables. I have seen various code snippets that will relink using a password secured Access mdb (using ADOX) but none that use a Workgroup security file. Has anyone got any ideas on this???
This is the code that I have found....
Private adoCn As ADODB.Connection
Private adoCat As New ADOX.Catalog
Private adoTable As New ADOX.Table
Private Sub Form_Load()
Dim ConnStr As String
' This is the database where you want the link to be created
ConnStr = "MainDataBase.mdb"
Set adoCn = New ADODB.Connection
With adoCn
.Provider = "Microsoft.JET.OLEDB.4.0;Jet OLEDB
atabase Password=admin"
.Open ConnStr
End With
End Sub
and....
Private Sub cmdCreate_Click()
Set adoCat = New ADOX.Catalog
Set adoCat.ActiveConnection = adoCn
Set adoTable.ParentCatalog = adoCat
With adoTable
' The name of the table you want to link
.Name = "TABLENAME"
' The source database where the linked table is held
.Properties("Jet OLEDB:Link Datasource"
= "SourceDataBase.mdb"
.Properties("Jet OLEDB:Link Provider String"
= "MS Access;Pwd=admin"
' Again the name of the table you wish to link
.Properties("Jet OLEDB:Remote Table Name"
= "TABLENAME"
.Properties("Jet OLEDB:Create Link"
= True
' Add the table to the Linked database
adoCat.Tables.Append adoTable
End With
End Sub
Regards,
Alan
This is the code that I have found....
Private adoCn As ADODB.Connection
Private adoCat As New ADOX.Catalog
Private adoTable As New ADOX.Table
Private Sub Form_Load()
Dim ConnStr As String
' This is the database where you want the link to be created
ConnStr = "MainDataBase.mdb"
Set adoCn = New ADODB.Connection
With adoCn
.Provider = "Microsoft.JET.OLEDB.4.0;Jet OLEDB
.Open ConnStr
End With
End Sub
and....
Private Sub cmdCreate_Click()
Set adoCat = New ADOX.Catalog
Set adoCat.ActiveConnection = adoCn
Set adoTable.ParentCatalog = adoCat
With adoTable
' The name of the table you want to link
.Name = "TABLENAME"
' The source database where the linked table is held
.Properties("Jet OLEDB:Link Datasource"
.Properties("Jet OLEDB:Link Provider String"
' Again the name of the table you wish to link
.Properties("Jet OLEDB:Remote Table Name"
.Properties("Jet OLEDB:Create Link"
' Add the table to the Linked database
adoCat.Tables.Append adoTable
End With
End Sub
Regards,
Alan