Information générale
Titre:
Problem with making an ODBC connection.
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement