Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Access Modules daovba ado > Multiple DNS-Le...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 1536 of 1609
Post > Topic >>

Multiple DNS-Less Connections

by =?Utf-8?B?VEVCMg==?= <TEB2@[EMAIL PROTECTED] > Aug 5, 2008 at 02:16 PM

Access 2007 connecting to SQL Server

I'm using an AutoExec marco to call the function and it works great with
one 
table.  How can I modify the code below to create links to more that one 
table?

Option Explicit

Function AttachDSNLessTable(stLocalTableName As String, stRemoteTableName
As 
String, stServer As String, stDatabase As String, Optional stUsername As 
String, Optional stPassword As String)
    
    On Error GoTo AttachDSNLessTable_Err
    
    Dim td As TableDef
    Dim stConnect As String
    
    For Each td In CurrentDb.TableDefs
        If td.Name = stLocalTableName Then
            CurrentDb.TableDefs.Delete stLocalTableName
        End If
    Next
      
    If Len(stUsername) = 0 Then
        stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & 
";DATABASE=" & stDatabase & ";Trusted_Connection=Yes"
    Else
        stConnect = "ODBC;DRIVER=SQL Server;SERVER=" & stServer & 
";DATABASE=" & stDatabase & ";UID=" & stUsername & ";PWD=" & stPassword
    End If
    
    Set td = CurrentDb.CreateTableDef(stLocalTableName, dbAttachSavePWD, 
stRemoteTableName, stConnect)
    CurrentDb.TableDefs.Append td
    AttachDSNLessTable = True
    
    Exit Function

AttachDSNLessTable_Err:
    AttachDSNLessTable = False
    MsgBox "AttachDSNLessTable encountered an unexpected error: " & 
Err.Description

End Function
 




 2 Posts in Topic:
Multiple DNS-Less Connections
=?Utf-8?B?VEVCMg==?= <  2008-08-05 14:16:05 
Re: Multiple DNS-Less Connections
"Douglas J. Steele&q  2008-08-05 17:29:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Nov 20 3:22:14 CST 2008.