Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting the server name from an ODBC Data Source
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00312048
Message ID:
00312168
Vues:
17
Well, the easy answer is that the info's stored in the registry so the following code returns the server name given the DSN:
* Program....: GETSERVER.PRG
* Version....: 1.0
* Author.....: Andrew Coates
* Date.......: January 4, 2000
* Notice.....: Copyright © 2000 Civil Solutions, All Rights Reserved.
* Compiler...: Visual FoxPro 06.00.8492.00 for Windows
* Abstract...: gets the server name given a DSN name
* Changes....:

lParameters tcDSN

#DEFINE HKEY_LOCAL_MACHINE          -2147483646  && BITSET(0,31)+2

set classlib to (home() + '\ffc\registry.vcx') addi
oReg = create('registry')

local lcServerName
lcServerName = ''

oReg.GetRegKey("Server", @lcServerName, 'Software\ODBC\ODBC.INI\' + alltrim(tcDSN) , HKEY_LOCAL_MACHINE)

return lcServerName
Cheers,

Andrew

>Hi All,
>
>I'm trying to find out which server an ODBC data source is pointing at. I can get the DSN that a connection uses with DBGetProp as well as the database, userID and password. However, to make sure that the Crystal Report I'm automating is pointing at the server on which I've created the temporary table that it uses as its primary data source, I need to know the server name.
>
>The ConnectionString property is empty (because I've used the DSN route for the connection definition).
>
>I've been scouring the MSDN docs for an appropriate SQLGet* function, but to no avail.
>
>Any hints anyone (I'd love to hear that I've missed something obvious)?
>
>Cheers,
>
>Andrew


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform