Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

create linked table
I need to create a table in Access which is linked to a SQL Server table.
Here's the code I'm trying to use:

Dim catDB As ADOX.Catalog
Dim tblLink As ADOX.Table
Dim sLocalDB As String
Dim sProv As String

On Error GoTo ErrorHandler
Set catDB = New ADOX.Catalog
sLocalDB = IniLineRead(sIniFileName, "LOCATIONS", "LocalDB")
catDB.ActiveConnection = sLocalDB
Set tblLink = New ADOX.Table

With tblLink
.Name = "Test_Server"
Set .ParentCatalog = catDB
sProv = "ODBC;Data Source=GVLSNT113;Initial Catalog=CPFdb;" + _
"User ID=;Password=;"
.Properties("Jet OLEDB:Create Link") = True
.Properties("Jet OLEDB:Link Provider String") = sProv
.Properties("Jet OLEDB:Remote Table Name") = "dbo.CallReportCategory"
End With
catDB.Tables.Append tblLink
Set catDB = Nothing

I'm getting an ODBC error on the .append method.

What have I missed?

Report this thread to moderator Post Follow-up to this message
Old Post
Erin
09-27-04 08:55 PM


Re: create linked table
On Mon, 27 Sep 2004 07:37:02 -0700, "Erin" <Erin@discussions.microsoft.com> 
wrote:

¤ I need to create a table in Access which is linked to a SQL Server table.
¤ Here's the code I'm trying to use:
¤
¤     Dim catDB As ADOX.Catalog
¤     Dim tblLink As ADOX.Table
¤     Dim sLocalDB As String
¤     Dim sProv As String
¤
¤     On Error GoTo ErrorHandler
¤     Set catDB = New ADOX.Catalog
¤     sLocalDB = IniLineRead(sIniFileName, "LOCATIONS", "LocalDB")
¤     catDB.ActiveConnection = sLocalDB
¤     Set tblLink = New ADOX.Table
¤
¤     With tblLink
¤         .Name = "Test_Server"
¤         Set .ParentCatalog = catDB
¤         sProv = "ODBC;Data Source=GVLSNT113;Initial Catalog=CPFdb;" + _
¤                 "User ID=;Password=;"
¤         .Properties("Jet OLEDB:Create Link") = True
¤         .Properties("Jet OLEDB:Link Provider String") = sProv
¤         .Properties("Jet OLEDB:Remote Table Name") = "dbo.CallReportCatego
ry"
¤     End With
¤     catDB.Tables.Append tblLink
¤     Set catDB = Nothing
¤
¤ I'm getting an ODBC error on the .append method.
¤
¤ What have I missed?

I think your link provider string may be incorrect. Here is a simple example
:

sProv = "ODBC;Driver={SQL Server};" & _
"Server=(local);" & _
"Database=Northwind;" & _
"Uid=sa;" & _
"Pwd="


Paul ~~~ pclement@ameritech.net
Microsoft MVP (Visual Basic)

Report this thread to moderator Post Follow-up to this message
Old Post
Paul Clement
09-28-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:34 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.