Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

How To Delete ODBC Data Source Using SqlConfigDataSource


View products that this article applies to.

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.

↑ Back to the top


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.

↑ Back to the top


References

To programmatically create a data source, please see the following article in the Microsoft Knowledge Base:
142216 How To Create ODBC Data Sources Using SqlConfigDataSource

↑ Back to the top


Keywords: KB195262, kbhowto, kbdatabase

↑ Back to the top

Article Info
Article ID : 195262
Revision : 5
Created on : 3/7/2005
Published on : 3/7/2005
Exists online : False
Views : 501