Create Linked table in Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am try to link a SQL 2000 table to Access 2000 using VB.Net 2003

Here is my code:

Dim Con As New ADODB.Connection
Dim Cat As New ADOX.Catalog
Dim tbl As New ADOX.Table

Con.Open(m_sAccessDbPath)
Cat.ActiveConnection = Con

' Name the new Table and set its ParentCatalog property
' to the open Catalog to allow access to the Properties
' collection.
tbl.Name = m_sAccessDbTableName
tbl.ParentCatalog = Cat

' Set the properties to create the link.
tbl.Properties("Jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Link Provider String") = RemoteDbPath
tbl.Properties("Jet OLEDB:Remote Table Name") = RemoteTableName

' Append the table to the Tables collection.
Cat.Tables.Append(tbl)

The problem is, I have 3 build errors:
Property 'Item' is 'ReadOnly'.
On:
tbl.Properties("Jet OLEDB:Create Link") = True
tbl.Properties("Jet OLEDB:Link Provider String") = RemoteDbPath
tbl.Properties("Jet OLEDB:Remote Table Name") = RemoteTableName

The ADOX I am useing is:
Microsoft ADO Ext. 2.7 for DDL and Security

What am I doing wrong?
Thanks for you help
 
Well, it COULD be because the line(s) don't expliccitly specify the property
you wish to set (remember VB.NET doesn't have the concept of default
properties).

Try something like this:
tbl.Properties("Jet OLEDB:Create Link").Value = True

so that you are explictly saying you want to set the value of that item in
the Properties collection.

And I'm making a (reasonable) guess that you need the word "Value" - it
could be something else...

(e-mail address removed)
 
Back
Top