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
To delete a user or system data source programmatically
To delete a file data source
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);
}