VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

This code snippet creates a DSN at runtime. The parameters are read through an INI file.

Kaustubh Zoal  (10 Submissions)   Windows API Call/Explanation   VB 6.0   Unknown Difficulty   Fri 21st June 2002   Mon 8th February 2021

This code snippet creates a DSN at runtime. The parameters are read through an INI file.

API Declarations



'Constant Declaration
Private Const ODBC_ADD_DSN = 1 ' Add data source
Private Const ODBC_ADD_SYS_DSN = 4 'Add System DSN
Private Const ODBC_CONFIG_DSN = 2 ' Configure (edit) data source
Private Const ODBC_REMOVE_DSN = 3 ' Remove data source
Private Const vbAPINull As Long = 0 ' NULL Pointer

'Function Declare
#If Win32 Then
Private Declare Function SQLConfigDataSource Lib "ODBCCP32.DLL" _
(ByVal hwndParent As Long, ByVal fRequest As Long, _
ByVal lpszDriver As String, ByVal lpszAttributes As String) _
As Long
#Else
Private Declare Function SQLConfigDataSource Lib "ODBCINST.DLL" _
(ByVal hwndParent As Integer, ByVal fRequest As Integer, ByVal _
lpszDriver As String, ByVal lpszAttributes As String) As Integer
#End If

Private Declare Function SQLGetInstalledDriver Lib "ODBCCP32.DLL" _
(ByVal lDrvList As String, ByVal lpszDriver As Long, ByVal lpszAttributes As Long) As Long

Dim db As ADODB.Connection
Dim rs As ADODB.Recordset
Dim dbPath As String

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long


Rate This code snippet creates a DSN at runtime. The parameters are read through an INI file. (1(1 Vote))
This code snippet creates a DSN at runtime. The parameters are read through an INI file..bas

This code snippet creates a DSN at runtime. The parameters are read through an INI file. Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters