Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract Server name from ODBC DSN

Status
Not open for further replies.

jdam

IS-IT--Management
Jan 19, 2005
104
CA
Hi

I have ODBC connection to a sql server. I need code that can get the name of the server the current ODBC is connected to.

IE. ODBC;DSN=testcompany;Uid;pwd

I need to know the name of the server the testcompany is being hosted on. Any suggestions.
 
Perhaps this could help you:

Function Datafil(Tabel)
On Error GoTo Fejl
Dim ResStr As String, DB As DAO.Database
Set DB = CurrentDb()

ResStr = DB.TableDefs(Tabel).Connect
If Left(ResStr, 4) = "ODBC" Then ResStr = " " & Left(ResStr, InStr(1, ResStr, "PWD=") - 2) & Right(ResStr, InStr(1, ResStr, "App=") - 1)
Datafil = Right(ResStr, Len(ResStr) - 10)
Fejl_Exit:
Exit Function
Fejl:
'MsgBox Err.Description, , "YrAppName"
Resume Fejl_Exit
End Function

Solution 2:
SELECT MSysObjects.Connect, MSysObjects.Database, MSysObjects.ForeignName, MSysObjects.Name
FROM MSysObjects
WHERE (((MSysObjects.Type)=4 Or (MSysObjects.Type)=6));



Herman

They say that crime doesn't pay... does that mean my job is a crime?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top