Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than odbccp32, prefix the name with the module name and a period.
SQLGetPrivateProfileString (odbccp32)
.
C# Signature:
[DllImport("odbccp32.dll", SetLastError=true)]
static extern int SQLGetPrivateProfileString(string lpszSection, string lpszEntry, string lpszDefault, [Out] char[] retBuffer, int cbRetBuffer, string lpszFileName);
VB Signature:
Declare Function SQLGetPrivateProfileString Lib "odbccp32.dll" (TODO) As TODO
User-Defined Types:
None.
Sample Code:
This function persists a system data source with the provided name and connection string. Remember to add your own error checking mechanisms.
void UpdateDSN(string dataSourceName, string connStr)
{
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");
// 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);
}
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).