Create Linked table in Access

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kent

    #1

    Create Linked table in Access

    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.Connectio n
    Dim Cat As New ADOX.Catalog
    Dim tbl As New ADOX.Table

    Con.Open(m_sAcc essDbPath)
    Cat.ActiveConne ction = Con

    ' Name the new Table and set its ParentCatalog property
    ' to the open Catalog to allow access to the Properties
    ' collection.
    tbl.Name = m_sAccessDbTabl eName
    tbl.ParentCatal og = 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.Appe nd(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

  • alaspin

    #2
    RE: Create Linked table in Access

    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...

    alaspin@yahoo.c om

    "Kent" wrote:
    [color=blue]
    > 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.Connectio n
    > Dim Cat As New ADOX.Catalog
    > Dim tbl As New ADOX.Table
    >
    > Con.Open(m_sAcc essDbPath)
    > Cat.ActiveConne ction = Con
    >
    > ' Name the new Table and set its ParentCatalog property
    > ' to the open Catalog to allow access to the Properties
    > ' collection.
    > tbl.Name = m_sAccessDbTabl eName
    > tbl.ParentCatal og = 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.Appe nd(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
    >[/color]

    Comment

    • Kent

      #3
      RE: Create Linked table in Access

      That did it, None of the MS examles show this.
      Thanks.

      "alaspin" wrote:
      [color=blue]
      > 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...
      >
      > alaspin@yahoo.c om
      >
      > "Kent" wrote:
      >[color=green]
      > > 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.Connectio n
      > > Dim Cat As New ADOX.Catalog
      > > Dim tbl As New ADOX.Table
      > >
      > > Con.Open(m_sAcc essDbPath)
      > > Cat.ActiveConne ction = Con
      > >
      > > ' Name the new Table and set its ParentCatalog property
      > > ' to the open Catalog to allow access to the Properties
      > > ' collection.
      > > tbl.Name = m_sAccessDbTabl eName
      > > tbl.ParentCatal og = 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.Appe nd(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
      > >[/color][/color]

      Comment

      • SCM

        #4
        RE: Create Linked table in Access

        Anyone has VC++ sample code on this topic
        --
        Regards,
        SCM
        Programmer


        "Kent" wrote:
        [color=blue]
        > 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.Connectio n
        > Dim Cat As New ADOX.Catalog
        > Dim tbl As New ADOX.Table
        >
        > Con.Open(m_sAcc essDbPath)
        > Cat.ActiveConne ction = Con
        >
        > ' Name the new Table and set its ParentCatalog property
        > ' to the open Catalog to allow access to the Properties
        > ' collection.
        > tbl.Name = m_sAccessDbTabl eName
        > tbl.ParentCatal og = 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.Appe nd(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
        >[/color]

        Comment

        Working...