Solved

How to link a SQL SERVER table to access?

Posted on 2001-09-03
7
200 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

919 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now