home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1998 October / dpcb1098.iso / Business / Maxim / MAX5 / data.z / ODBCLgin.frm < prev    next >
Text File  |  1998-05-10  |  6KB  |  177 lines

  1. VERSION 5.00
  2. Begin VB.Form frmODBCLogon 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Maximizer ODBC Login"
  5.    ClientHeight    =   2505
  6.    ClientLeft      =   2850
  7.    ClientTop       =   1755
  8.    ClientWidth     =   4470
  9.    ControlBox      =   0   'False
  10.    Icon            =   "ODBCLgin.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2505
  15.    ScaleWidth      =   4470
  16.    ShowInTaskbar   =   0   'False
  17.    StartUpPosition =   2  'CenterScreen
  18.    Begin VB.CommandButton cmdCancel 
  19.       Cancel          =   -1  'True
  20.       Caption         =   "&Cancel"
  21.       Height          =   450
  22.       Left            =   2520
  23.       TabIndex        =   7
  24.       Top             =   1800
  25.       Width           =   1440
  26.    End
  27.    Begin VB.CommandButton cmdOK 
  28.       Caption         =   "&OK"
  29.       Default         =   -1  'True
  30.       Height          =   450
  31.       Left            =   480
  32.       TabIndex        =   6
  33.       Top             =   1800
  34.       Width           =   1440
  35.    End
  36.    Begin VB.Frame fraStep3 
  37.       Caption         =   "Connection Values"
  38.       Height          =   1455
  39.       Index           =   0
  40.       Left            =   120
  41.       TabIndex        =   8
  42.       Top             =   120
  43.       Width           =   4230
  44.       Begin VB.TextBox txtUID 
  45.          Height          =   300
  46.          Left            =   1125
  47.          TabIndex        =   3
  48.          Top             =   600
  49.          Width           =   3015
  50.       End
  51.       Begin VB.TextBox txtPWD 
  52.          Height          =   300
  53.          IMEMode         =   3  'DISABLE
  54.          Left            =   1125
  55.          PasswordChar    =   "*"
  56.          TabIndex        =   5
  57.          Top             =   930
  58.          Width           =   3015
  59.       End
  60.       Begin VB.ComboBox cboDSNList 
  61.          Height          =   315
  62.          ItemData        =   "ODBCLgin.frx":000C
  63.          Left            =   1125
  64.          List            =   "ODBCLgin.frx":000E
  65.          Sorted          =   -1  'True
  66.          Style           =   2  'Dropdown List
  67.          TabIndex        =   1
  68.          Top             =   240
  69.          Width           =   3000
  70.       End
  71.       Begin VB.Label lblStep3 
  72.          AutoSize        =   -1  'True
  73.          Caption         =   "&DSN:"
  74.          Height          =   195
  75.          Index           =   1
  76.          Left            =   135
  77.          TabIndex        =   0
  78.          Top             =   285
  79.          Width           =   390
  80.       End
  81.       Begin VB.Label lblStep3 
  82.          AutoSize        =   -1  'True
  83.          Caption         =   "&User ID:"
  84.          Height          =   195
  85.          Index           =   2
  86.          Left            =   135
  87.          TabIndex        =   2
  88.          Top             =   630
  89.          Width           =   585
  90.       End
  91.       Begin VB.Label lblStep3 
  92.          AutoSize        =   -1  'True
  93.          Caption         =   "&Password:"
  94.          Height          =   195
  95.          Index           =   3
  96.          Left            =   135
  97.          TabIndex        =   4
  98.          Top             =   975
  99.          Width           =   735
  100.       End
  101.    End
  102. End
  103. Attribute VB_Name = "frmODBCLogon"
  104. Attribute VB_GlobalNameSpace = False
  105. Attribute VB_Creatable = False
  106. Attribute VB_PredeclaredId = True
  107. Attribute VB_Exposed = False
  108. '==========================================================================
  109. '
  110. '  This code and information is provided "as is" without warranty of any
  111. '  kind, either expressed or implied, including but not limited to the
  112. '  implied warranties of merchantability and/or fitness for a particular
  113. '  purpose..
  114. '
  115. '  Copyright (c) 1998  Multiactive Software Inc.  All Rights Reserved.
  116. '
  117. '==========================================================================
  118.  
  119. Option Explicit
  120. Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer
  121. Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
  122. Const SQL_SUCCESS As Long = 0
  123. Const SQL_FETCH_NEXT As Long = 1
  124.  
  125.  
  126. Private Sub cmdCancel_Click()
  127.     Unload Me
  128. End Sub
  129.  
  130. Private Sub cmdOK_Click()
  131.  
  132. DSN = cboDSNList.Text   'The DSN name
  133. UID = txtUID.Text       'The User Id
  134. PWD = txtPWD.Text       'The password for the database
  135.  
  136. 'Open the database
  137. Set dbs = OpenDatabase("", False, False, "ODBC;DSN=" & DSN & ";UID=" & UID & ";PWD=" & PWD & ";")
  138.  
  139.     Load Persform   'Show the form
  140.  
  141. End Sub
  142.  
  143. Private Sub Form_Load()
  144.     GetDSNs         'Get all the DSN names from ODBC
  145. End Sub
  146.  
  147. 'Created by VB
  148. Sub GetDSNs()       'Get all the DSN names from ODBC
  149.     On Error Resume Next
  150.     
  151.     Dim i As Integer
  152.     Dim sDSNItem As String * 1024
  153.     Dim sDRVItem As String * 1024
  154.     Dim sDSN As String
  155.     Dim sDRV As String
  156.     Dim iDSNLen As Integer
  157.     Dim iDRVLen As Integer
  158.     Dim lHenv As Long         'handle to the environment
  159.  
  160.     cboDSNList.AddItem "(None)"
  161.  
  162.     'get the DSNs
  163.     If SQLAllocEnv(lHenv) <> -1 Then
  164.         Do Until i <> SQL_SUCCESS
  165.             sDSNItem = Space(1024)
  166.             i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen)
  167.             sDSN = VBA.Left(sDSNItem, iDSNLen)
  168.                 
  169.             If sDSN <> Space(iDSNLen) Then
  170.                 cboDSNList.AddItem sDSN
  171.             End If
  172.         Loop
  173.     End If
  174.     cboDSNList.ListIndex = 0
  175.     
  176. End Sub
  177.