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.
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.dll"
( ByVal hwndParent As IntPtr,
ByVal fRequest As Integer,
ByVal lpszDriver As String,
ByVal lpszAttributes As String) As Boolean
User-Defined Types:
TODO
Notes:
[2004-10-19 - Nicholas Paldino]
Fixed the declaration (from int to short), as well as cleaned up incorrect code.
Tips & Tricks:
Add some.
Sample Code:
Try out this VB.NET class to create User and System DSNs. [Rob]
Private Const ODBC_ADD_DSN As Integer = 1 '(use this to add a user DSN)
Private Const ODBC_CONFIG_DSN As Integer = 2 '(use this to configure a user DSN)
Private Const ODBC_REMOVE_DSN As Integer = 3 '(use this to remove a user DSN)
Private Const ODBC_ADD_SYS_DSN As Integer = 4 '(use this to add a system DSN)
Private Const ODBC_CONFIG_SYS_DSN As Integer = 5 '(use this to configure a system DSN)
Private Const ODBC_REMOVE_SYS_DSN As Integer = 6 '(use this to remove a system DSN)
' BlankDate (NULL or blank)
' CatConnect (Y or N)
' CatSchemaNULL (Y or N)
' ConvertThreePartNames (Y or N)
' Database
' Date1582 (NULL or blank)
' Description
' Driver
' Numeric_overflow (Ignore or blank)
' Prompt(Y or N)
' RoleName
' RolePWD
' SelectLoops (Y or N)
' Server
' ServerDelimitedCase
' ServerMaxColumnNameLen
' ServerMaxColumns
' ServerMaxSchemaNameLen
' ServerMaxTableNameLen
' ServerNameCase
' ServerType
' ServerVersion
' SupportIIDECIMAL (Y or N)
' UseSysTables (Y or N)
' WithOption (Refers to Enterprise Gateway with Options)
' Create/Configure
Public Shared Function CreateIngresDB_DSN(ByVal DSName As String, ByVal description As String, ByVal server As String, ByVal db As String, ByVal type As ADD_TYPE, ByVal prompt As Boolean) As Boolean
Dim promptStr As String = "N"
Dim odbc_const As Integer = 0
Dim reg As Microsoft.Win32.RegistryKey
If prompt Then
promptStr = "Y"
End If
Select Case type
Case ADD_TYPE.USER
reg = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\ODBC\ODBC.INI\" & DSName)
Case ADD_TYPE.SYSTEM
reg = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("Software\ODBC\ODBC.INI\" & DSName)
End Select
If reg Is Nothing Then
odbc_const = type
Else
Select Case type
Case ADD_TYPE.USER
odbc_const = ODBC_CONFIG_DSN
Case ADD_TYPE.SYSTEM
odbc_const = ODBC_CONFIG_SYS_DSN
Public Shared Function RemoveIngresDB_DSN(ByVal DSName As String, ByVal type As REMOVE_TYPE) As Boolean
Return DoDataSource(New IntPtr(0), _
type, _
"Ingres", _
"DSN=" & DSName & Chr(0))
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
' MS Access
Public Shared Function CreateAccessDB_DSN(ByVal DSName As String, ByVal DBPath As String) As Boolean
Return DoDataSource(New IntPtr(0), _
4, _
"Microsoft Access Driver (*.MDB)", _
"DSN=" & DSName & ";Uid=Admin;pwd=;DBQ=" & DBPath & ";")
End Function
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' ODBC Api Call
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.dll" (ByVal hwndParent As IntPtr, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean
Private Shared Function DoDataSource(ByVal hwndParent As IntPtr, ByVal fRequest As Integer, ByVal lpszDriver As String, ByVal lpszAttributes As String) As Boolean
Return SQLConfigDataSource(hwndParent, fRequest, lpszDriver, lpszAttributes)
End Function
End Class
Alternative Managed API:
Do you know one? Please contribute it!
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).