Solved

How to link a SQL SERVER table to access?

Posted on 2001-09-03
7
203 Views
Last Modified: 2008-07-03
On my project I linked an access table from one access DB to another using ADOX. Now I wanted to link a table from SQL SERVER to ACCESS DB. Can anybody help me on how to handle this?

Thanks
0
Comment
Question by:revathi
  • 4
  • 3
7 Comments
 
LVL 1

Expert Comment

by:dekeldate
ID: 6451705
You could use something like this

I have used a DSN as the ODBC connection string to connect to the Pubs sample database on SQL Server.

Sub CreateLinkSQL()

   dim strTargetDB As String, _
       strProviderString As String, _
       strSourceTbl As String, _
       strLinkTblName As String)

   strTargetDB = "C:\Program Files\Microsoft zffice\Office\Samples\Northwind.mdb"
   strProviderString = "ODBC;DSN=Publishers;UID=sa;PWD=;DATABASE=pubs;"
   strSourceTbl = "dbo.Authors"
   strLinkTblName = "LinkedODBC"

   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


hope this helps
0
 

Author Comment

by:revathi
ID: 6459601
Thank you expert!. While I am using 'Link provider string' property I am getting error stating 'Couldnot find installable ISAM' . I don't know the reason of this error. But if I use 'Link datasource' property I am not getting any such errors. Can you tell me why is this happening?
0
 
LVL 1

Accepted Solution

by:
dekeldate earned 200 total points
ID: 6459883
hi
This is probably because the path to the ISAM driver in your Windows Registry is invalid, or the ISAM driver does not exist.

check this kb article
http://support.microsoft.com/support/kb/articles/Q209/8/05.ASP
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:revathi
ID: 6466976
Thank you Expert!
0
 

Author Comment

by:revathi
ID: 6466977
Thank you Expert!
0
 

Author Comment

by:revathi
ID: 6466978
Thank you Expert!
0
 
LVL 1

Expert Comment

by:dekeldate
ID: 6468201
Thank you :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

730 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