> For the complete documentation index, see [llms.txt](https://pinvokeisalive.gitbook.io/pinvoke/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pinvokeisalive.gitbook.io/pinvoke/desktopfunctions/odbccp32/sqlsetconfigmode.md).

# SQLSetConfigMode

### C# Signature:

```cs
[DllImport("odbccp32.dll", SetLastError=true)]
static extern bool SQLSetConfigMode(ConfigMode configMode);
```

### VB Signature:

```cs
Declare Function SQLSetConfigMode Lib "odbccp32.dll" (TODO) As TODO
```

### User-Defined Types:

```cs
ODBC_BOTH_DSN = 0,
    ODBC_USER_DSN = 1,
    ODBC_SYSTEM_DSN = 2,
```

### Sample Code:

```cs
char[] value = new char[8192];

    // Try to retrieve the driver for the data source
    SQLSetConfigMode(ConfigMode.ODBC_SYSTEM_DSN);
    SQLGetPrivateProfileString(dataSourceName, "Driver", "", value, value.Length, "odbc.ini");

    // Set our configuration mode
    RequestFlags configMode = value[0] == '\0' ? RequestFlags.ODBC_ADD_SYS_DSN : RequestFlags.ODBC_CONFIG_SYS_DSN;

    // Connection string for SQLConfigDataSource must be null-
    // character delimited and double null-terminated
    string s = connStr.Replace(';', '\0');
    s += '\0';

    // Persist the data source
    SQLConfigDataSourceW(0, configMode, MY_DRIVER_NAME_STRING, s);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://pinvokeisalive.gitbook.io/pinvoke/desktopfunctions/odbccp32/sqlsetconfigmode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
