Microsoft KB Archive/195262

= How To Delete ODBC Data Source Using SqlConfigDataSource =

Article ID: 195262

Article Last Modified on 3/7/2005

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition
 * Microsoft Data Access Components 2.5

-



This article was previously published under Q195262



SUMMARY
This article describes how to programmatically remove an existing ODBC datasource instead of manually removing it through the ODBC Administrator. You can use the SqlConfigDataSource function in Odbccp32.dll for this purpose.



MORE INFORMATION
The following sample code demonstrates how to use this API function to remove a Visual FoxPro Database datasource. To use this code, you need to create a datasource called rmtest that points to the data1.dbc in your local hard drive. DECLARE Integer SQLConfigDataSource IN odbccp32.dll Integer, ; Integer, String, String DriverName="Microsoft Visual FoxPro Driver" IsRemove =SQLConfigDataSource(1,3,DriverName, "DSN=rmtest" + CHR(0)+;              "Description=david test"+CHR(0)+;               "SourceDB=C:\TEMP\data1.dbc"+CHR(0)+;               "SourceType=DBC") IF IsRemove>0 WAIT WINDOW "Deleted" ELSE WAIT WINDOW "Delete failed" ENDIF Note that the "Description=david test" portion of the connection string can be omitted and the datasource will still be removed.

