Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with making an ODBC connection.
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Problem with making an ODBC connection.
Divers
Thread ID:
00907978
Message ID:
00907978
Vues:
51
I was toying around with a code sample that I found in the may 2003 FoxPro Advisor that created an ODBC connection programmatically. What I have found is that while the connection is created I cannot configure it or delete it. When I try I get the message to:

"The setup routines for the sqlserver ODBC driver could not be found. Please reinstall the driver."

I followed the example just as it was printed which is as follows:

Lparameters tcname,tcdname,tcdesc,tcserver

Local lcsqldriver, lcini, lcuser, loreg, lnerr

lcsqldriver = Getenv("windir")+"\system32\sqlsrv32.dll"

If !File(lcsqldriver)
Messagebox("SQL ODBC connection needs to be installed for this program to run.",16,"Data validation")
Return
Endif

loreg = Newobject("registry","P:\dev\Source\PBINew8\registry.vcx")

lcuser = Getenv("USERNAME")

#Define HKEY_LOCAL_MACHINE -2147483646

lcini = "software\odbc\odbc.ini\"

If loreg.iskey(lcini+tcname,HKEY_LOCAL_MACHINE)
Messagebox("The connection already exists.",16,"Data validation.")
Return
Endif

lnerr = loreg.setregkey(tcname,'sqlserver',lcini+"ODBC data sources",HKEY_LOCAL_MACHINE,.T.)

If lnerr = 0
lnerr = loreg.setregkey("database",tcdname,lcini+tcname,HKEY_LOCAL_MACHINE,.T.)
Endif

If lnerr = 0
lnerr = loreg.setregkey("Description",tcdesc,lcini+tcname,HKEY_LOCAL_MACHINE,.T.)
Endif

If lnerr = 0
lnerr = loreg.setregkey("driver",lcsqldriver,lcini+tcname,HKEY_LOCAL_MACHINE,.T.)
Endif

If lnerr = 0
lnerr = loreg.setregkey("lastuser",lcuser,lcini+tcname,HKEY_LOCAL_MACHINE,.T.)
Endif

If lnerr = 0
lnerr = loreg.setregkey("server",tcserver,lcini+tcname,HKEY_LOCAL_MACHINE,.T.)
Endif

If lnerr = 0
Messagebox("Successful ODBC installation........",64,"Installation complete.")
Else
Messagebox("An error has occured. No ODBC connection installed.",16,"Installation failed.")
Endif


Did I miss something? What could be going wrong?

Thanks in advance
Kelly
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform