HOW TO FIND ODBC DRIVER THROUGH TD APPLICATION

General discussion forum about all databases other than SqlBase.
raghava

HOW TO FIND ODBC DRIVER THROUGH TD APPLICATION

Post by raghava » 01 Oct 2011, 11:27

I have database in MS-ACCESS & MS-SQL SERVER,

I am connecting to the database through Data Sources (ODBC),
how to find which ODBC Driver through TD-Application, is there any Command to find vendor of the Database.
You do not have the required permissions to view the files attached to this post.

ColdBeer16

Re: HOW TO FIND ODBC DRIVER THROUGH TD APPLICATION

Post by ColdBeer16 » 13 Jan 2012, 23:11

There are several ways to do this, for example you can issue this query:

!!CB!! 129
Set sSql = 'SELECT CmptLevel FROM Master.dbo.sysdatabases WHERE Name = \'master\' INTO :nCompatibilityLevel'
Call SqlPrepareAndExecute( g_hSql, sSql )
Call SqlFetchNext( g_hSql, nInd )

Suppress any errors, if it returns successfully you know which compatibility level of MSS you have.

You can also look up the registry for info of the ODBC definition. Here's sample code for how to grab the SQLServer DB name from the ODBC setup based on remotedbname in SQL.INI. You can adapt to get other ODBC info. Good luck.

!!CB!! 70
If SalFileOpen( fhFile, 'SQL.INI', OF_Read | OF_Share_Deny_None )
! Scan file
Loop
If NOT SalFileGetStr( fhFile, sLine, 2048 )
Break
If SalStrScan( SalStrTrimX( SalStrLowerX( sLine ) ), 'remotedbname=' || SalStrLowerX( SqlDatabase ) ) > -1 ! Found database name on this line
! Found the relevant line in the config file, now parse out the DSN
Set nPos = SalStrScan( sLine, 'DSN=' ) + 4
Set sDSN = SalStrRightX( sLine, SalStrLength( sLine ) - nPos )
! OK, now that we have the DSN name, let's check the registry to see what the database name is on the SQLServer side
Set oRegistry.m_RootKey = HKEY_LOCAL_MACHINE
Call oRegistry.ReadStringAt( '\\SOFTWARE\\ODBC\\ODBC.INI\\' || sDSN, 'Database', sDSNDatabaseName )
Set bOK = TRUE
Break
Call SalFileClose( fhFile )

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest