VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   1320
      Left            =   315
      TabIndex        =   0
      Top             =   630
      Width           =   3795
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function SQLAllocConnect Lib "odbc32.dll" (ByVal henv&, phdbc&) As Integer
Private Declare Function SQLAllocEnv Lib "odbc32.dll" (phenv&) As Integer
Private Declare Function SQLDriverConnect Lib "odbc32.dll" (ByVal hdbc&, ByVal hWnd As Long, ByVal szCSIn$, ByVal cbCSIn%, ByVal szCSOut$, ByVal cbCSMax%, cbCSOut%, ByVal fDrvrComp%) As Integer
Private Declare Function SQLGetInfoString Lib "odbc32.dll" Alias "SQLGetInfo" (ByVal hdbc&, ByVal fInfoType%, ByVal rgbInfoValue As String, ByVal cbInfoMax%, cbInfoOut%) As Integer
Private Declare Function SQLDisconnect Lib "odbc32.dll" (ByVal hdbc&) As Integer
Private Declare Function SQLFreeConnect Lib "odbc32.dll" (ByVal hdbc&) As Integer
Private Declare Function SQLFreeEnv Lib "odbc32.dll" (ByVal henv&) As Integer
Private Declare Function SQLDataSources Lib "odbc32.dll" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer

Const SQL_SUCCESS As Long = 0
Const SQL_DRIVER_NOPROMPT As Long = 0
Const SQL_IDENTIFIER_QUOTE_CHAR As Long = 29
Const SQL_FD_FETCH_NEXT As Long = &H1&

Private Sub Command1_Click()
On Error GoTo Cleanup

Dim iStatus As Integer
Dim iSize As Integer
Dim lEnv As Long
Dim lDBC As Long
Dim szResult As String * 8
Dim szConnect

  szConnect = "DSN=myodbc3-test;"

  'Initialise the ODBC subsystem
  If SQLAllocEnv(lEnv) <> 0 Then
    Exit Sub
  End If

  'Allocate space for the connection object
  If SQLAllocConnect(lEnv, lDBC) <> 0 Then
    GoTo Cleanup
  End If

  'Connect
  SQLDriverConnect lDBC, Me.hWnd, szConnect, Len(szConnect), szResult, Len(szResult), iSize, SQL_DRIVER_NOPROMPT

  'Get the quote char
  szResult = ""
  SQLGetInfoString lDBC, SQL_IDENTIFIER_QUOTE_CHAR, szResult, Len(szResult), iSize
  
  MsgBox Left(szResult, iSize)
  
Cleanup:
  On Error Resume Next
  If lDBC <> 0 Then SQLDisconnect lDBC
  SQLFreeConnect lDBC
  If lEnv <> 0 Then SQLFreeEnv lEnv
End Sub
