Create Linked table in Access

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
 
G

Guest

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top