I have differnt PC with diffent connections so I made a table of the users PC, then set accordingly
some were set to
SQL server Native client 11.0
or
SQL server
or
SQL server Native client 10.0
so I put each PC in a table with their setting , then had the code look it up:
Code:
Public Sub Connect2Db()
Dim sConnect, sDriver, sServer, sDB
sServer = "myServer"
sDB = "myDb"
sDriver = getOdbcDriver()
sConnect = "ODBC;DRIVER=" & sDriver & ";SERVER=" & sServer & ";DATABASE=" & sDB & ";Trusted_Connection=Yes"
End Sub
'Returns the computername
Function getPCName() As String
getPCName = Environ$("COMPUTERNAME")
End Function
Public Function getOdbcCon()
Dim vPC
vPC = getPCName()
getOdbcCon = DLookup("[ConnStr]", "tPcSettings", "[PCname]='" & vPC & "'") & ""
End Function