SQLConfigDataSource

C# Signature:

[DllImport("ODBCCP32.DLL",CharSet=CharSet.Unicode, SetLastError=true)]
static extern bool SQLConfigDataSourceW(IntPtr hwndParent , RequestFlags fRequest, string lpszDriver, string lpszAttributes);

VB Signature:

<DllImport("ODBCCP32.dll",CallingConvention:=CallingConvention.WinAPI,CharSet:=CharSet.Unicode,SetLastError:=True)> _
Public Shared Function SQLConfigDataSourceW(ByVal hwndParent As IntPtr, ByVal fRequest As UShort, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean

User-Defined Types:

ODBC_ADD_DSN = 1,
    ODBC_CONFIG_DSN = 2,
    ODBC_REMOVE_DSN = 3,
    ODBC_ADD_SYS_DSN = 4,
    ODBC_CONFIG_SYS_DSN = 5,
    ODBC_REMOVE_SYS_DSN = 6,
    ODBC_REMOVE_DEFAULT_DSN = 7

Tips & Tricks:

EG:
String.Format("CREATE_DBV4=\"{0}\" General\0", FileName);

Sample Code:

Sample Code:

Sample Code:

Última actualización