Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 2.61 KB

File metadata and controls

55 lines (41 loc) · 2.61 KB
title Delete a Data Source (ODBC)
description Learn how to delete a data source by using ODBC Administrator, programmatically, or using a file, before using ODBC applications with SQL Server 2005 or later.
author markingmyname
ms.author maghan
ms.date 08/01/2016
ms.service sql
ms.subservice native-client
ms.topic reference
helpviewer_keywords
data sources [ODBC]

Configuring the SQL Server ODBC Driver - Delete a Data Source

[!INCLUDESQL Server Azure SQL Database Synapse Analytics PDW]

Before using ODBC applications with [!INCLUDEssVersion2005] or later, you must know how to upgrade the version of the catalog stored procedures on earlier versions of [!INCLUDEssNoVersion] and add, delete, and test data sources.

You can delete a data source by using ODBC Administrator, programmatically (by using SQLConfigDataSource), or by deleting a file (if a file data source name).

To delete a data source by using ODBC Administrator

  1. In Control Panel, open Administrative Tools, and then double-click either ODBC Data Sources (64-bit) or ODBC Data Sources (32-bit). Alternatively, you can run odbcad32.exe from the command prompt.

  2. Click the User DSN, System DSN, or File DSN tab.

  3. Select the data source to delete.

  4. Click Remove, and then confirm the deletion.

Example

To programmatically delete a data source, call SQLConfigDataSource using either ODBC_REMOVE_DSN or ODBC_REMOVE_SYS_DSN as the second parameter.

The following sample shows how you can programmatically delete a data source.

// remove_odbc_data_source.cpp  
// compile with: ODBCCP32.lib user32.lib  
#include <iostream>  
#include \<windows.h>  
#include \<odbcinst.h>  
  
int main() {   
   LPCSTR provider = "SQL Server";   // Windows SQL Server Driver  
   LPCSTR provider = "SQL Server";   // Windows SQL Server driver  
   LPCSTR provider2 = "SQL Server Native Client 11.0";   // SQL Server 2012 Native Client driver  
   LPCSTR dsnname = "DSN=data2";  
   BOOL retval = SQLConfigDataSource(NULL, ODBC_REMOVE_DSN, provider, dsnname);  
   std::cout << retval;   // 1 if successful  
}  

See Also

Add a Data Source (ODBC)