How to delete a data source (ODBC)
You can delete a data source by using ODBC Administrator, programmatically (by using SQLConfigDataSource), or by deleting a file.
To delete a data source by using ODBC Administrator
- On the Start menu, point to Settings, and then click Control Panel.
- Double-click 32bit ODBC.
- Click the User DSN, System DSN, or File DSN tab.
- Click the data source to delete.
- Click Remove, and then confirm the deletion.
To delete a user or system data source programmatically
- Call SQLConfigDataSource with the fOption parameter set to either ODBC_REMOVE_DSN or ODBC_REMOVE_SYS_DSN.
To delete a file data source
- On the Start menu, point to Settings, and then click Control Panel.
- Double-click 32bit ODBC.
- Click the File DSN tab.
- Click the file DSN to delete.
- Click Remove.
Examples
This example shows data source removal by using SQLConfigDataSource. It has been simplified by removing error checking.
#include <stdio.h>
#include <windows.h>
#include "sql.h"
#include <odbcinst.h>
int main() {
RETCODE retcode;
UCHAR *szDriver = "SQL Server";
UCHAR *szAttributes = "DSN=MyFileDSN";
retcode = SQLConfigDataSource(NULL,
ODBC_REMOVE_DSN,
szDriver,
szAttributes);
}