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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ODBC connection

Status
Not open for further replies.

ajq98

Programmer
Jun 10, 2003
9
SA
Hi everybody,

I am pulling data from SQL Server 7.0 in my VFP application. I need to add a functionality in my VFP application to check if the computer on which this application is installed has an ODBC connection (DNS) created for SQL Server. If it does not have it, it should be created automatically.

Any thoughts or suggestions would be a big help. Thanks

AJQ
 
AJQ,

What I always do is to run SQLCONNECT(), passing the name of the DSN, at the start of the program. If it succeeds (i.e. it returns a positive integer), you can be sure that the DSN exists. It's not a particularly elegant solution, but if you can't find any other way, it will at least work.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Thank you much Mike. I had this solution in mind but SQLCONNECT failure is not necessarily because of not having DNS on that machine. There can be many other reasons like SQL Server is down or User ID has been changed or deleted or password changed etc. I just wanted to be more specific about the connection failure and I also want to create DNS through VFP application. Please advise

Thanks again
 
>> I need to add a functionality in my VFP application to check if the computer on which this application is installed has an ODBC connection (DNS) created for SQL Server. If it does not have it, it should be created automatically <<

You should check out the solution samples that ship with VFP.Under the Windows API category is a sample that illustrates reading information about ODBC drivers and datasources stored in the Windows Registry. To create the DSN if it doesn't exist, all you need to do is write the approariate information to the Windows Registry.



Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top