[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to Link a table from external Database?

Posted on 2001-08-15
5
Medium Priority
?
316 Views
Last Modified: 2008-02-01
I am doing a project where I need to create a link to user selected database (external database) from my current database on a particular table. I know how to do it in DAO. But I don't know how to do it using ADO. Quick response will help a lot

thanks in advance
0
Comment
Question by:revathi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
harsh008_k earned 800 total points
ID: 6391595
Sub CreateLinkedAccessTable(strDBLinkFrom As String, _
         strDBLinkTo As String, _
         strLinkTbl As String, _
         strLinkTblAs As String)

   Dim catDB As ADOX.Catalog
   Dim tblLink As ADOX.Table

   Set catDB = New ADOX.Catalog
   ' Open a Catalog on the database in which to create the link.
   catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
      "Data Source=" & strDBLinkFrom

   Set tblLink = New ADOX.Table
   With tblLink
      ' Name the new Table and set its ParentCatalog property to the
      ' open Catalog to allow access to the Properties collection.
      .Name = strLinkTblAs
      Set .ParentCatalog = catDB

      ' Set the properties to create the link.
      .Properties("Jet OLEDB:Create Link") = True
      .Properties("Jet OLEDB:Link Datasource") = strDBLinkTo
      .Properties("Jet OLEDB:Remote Table Name") = strLinkTbl
   End With

   ' Append the table to the Tables collection.
   catDB.Tables.Append tblLink

   Set catDB = Nothing
End Sub

0
 
LVL 1

Expert Comment

by:harsh008_k
ID: 6391599
Creating a Linked External Table
Even though ADO and ADOX distinguish between tables that are linked by using Jet I-ISAM drivers and tables linked from ODBC data sources, the method you use to create any linked external table is the same. To create a linked external table by using ADOX and the Microsoft Jet 4.0 OLE DB Provider, you must use the provider-specific Jet OLEDB:Link Provider String property to specify a Microsoft Jet connection string that tells how to connect to the external table. For I-ISAM tables, the connection string specifies the I-ISAM type and the path to the external data source. For ODBC tables, the connection string specifies the ODBC connection string that is necessary to connect to the data source. You then use the provider-specfic Jet OLEDB:Remote Table Name property to specify the name of the source table, which varies for the type of data you are linking to. For example, for an Excel worksheet, the source table can refer to an entire worksheet, a named range, or an unnamed range, whereas for Microsoft Exchange or Outlook, the source table refers to a folder in the mail storage. Just as when you create a linked Access table, you must also set the Jet OLEDB:Create Link property to True. The following code sample can be used to create a linked table for any I-ISAM or ODBC data source.

Sub CreateLinkedExternalTable(strTargetDB As String, _
         strProviderString As String, _
         strSourceTbl As String, _
         strLinkTblName As String)

   Dim catDB As ADOX.Catalog
   Dim tblLink As ADOX.Table

   Set catDB = New ADOX.Catalog
   ' Open a Catalog on the database in which to create the link.
   catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=" & strTargetDB

   Set tblLink = New ADOX.Table
   With tblLink
      ' Name the new Table and set its ParentCatalog property to the
      ' open Catalog to allow access to the Properties collection.
      .Name = strLinkTblAs
      Set .ParentCatalog = catDB

      ' Set the properties to create the link.
      .Properties("Jet OLEDB:Create Link") = True
      .Properties("Jet OLEDB:Link Provider String") = strProviderString
      .Properties("Jet OLEDB:Remote Table Name") = strLinkTbl
   End With

   ' Append the table to the Tables collection.
   catDB.Tables.Append tblLink

   Set catDB = Nothing
End Sub

0
 

Expert Comment

by:cpearl_s
ID: 6391646
hai,
More tips,
If u are trouble in giving connection string ,as above x-perts said,
just follow this.
Place a adodc control and in the properties set the driver and connect to oracle database. After test connection succeded , just copy that connection string and Use


0
 

Expert Comment

by:cpearl_s
ID: 6391647
hai,
More tips,
If u are trouble in giving connection string ,as above x-perts said,
just follow this.
Place a adodc control and in the properties set the driver and connect to oracle database. After test connection succeded , just copy that connection string and Use


regards
cpearl


0
 

Author Comment

by:revathi
ID: 6403564
Thank you for your timely help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question