Edit

Share via


SQLCreateDataSourceExW Function

Conformance
Version Introduced: ODBC 2.0

Summary
SQLCreateDataSourceExW adds a data source programmatically.

Warning

The SQLCreateDataSourceExW function is private and isn't meant to be used directly in your code. Microsoft doesn't support the use of this field in a production application under any circumstance.

Syntax

typedef enum tagDSNType
{
	evCreateAnyDSN,
	evCreateMachineDSN,
	evCreateUserDSN,
	evCreateSystemDSN,
	evCreateFileDSN
} DSN_TYPE;

#define		DSNC_ATTEMPT_CONN		0x00000001
#define		DSNC_DRIVER_ONLY		0x00000002

typedef struct tagODBCDSNCreationInfoW
{
	DWORD		dwSize;
	HWND		hwndParent;
	DSN_TYPE	DSNType;
	DSN_TYPE	DSNRestrictType;
	DWORD 		dwCIFlags;
	WCHAR		szDSNName[_MAX_PATH + 1];
	LPWSTR		szParentDir;
} ODBC_CREATE_DATASOURCE_INFOW;

BOOL INSTAPI SQLCreateDataSourceExW(
	ODBC_CREATE_DATASOURCE_INFOW * pCreateDSInfoW);

Arguments

pCreateDSInfoW
[Input] A struct of type ODBC_CREATE_DATASOURCE_INFOW see comments for descriptions.

Returns

SQLCreateDataSourceExW returns TRUE if the data source is created. Otherwise, it returns FALSE. See SqlCreateDataSource for diagnostic info about error codes when this function returns FALSE.

Comments

The ODBC_CREATE_DATASOURCE_INFOW has the following fields:

dwSize
A DWORD containing the size of the struct.

hwndParent
A handle to the parent directory of the data source.

DSNType
The type of DSN to create. See About Drivers and Data Sources to understand what these enums map to.

DSNRestrictType
The least restricted DSN type allowed.

dwCIFlags
A mask with bits for either DSNC_ATTEMPT_CONN or DSNC_DRIVER_ONLY.

szDSNName
Data source name.

szParentDir
The parent directory of the data source.

For information about See
Creating data sources SQLCreateDataSource