home *** CD-ROM | disk | FTP | other *** search
/ Computer Buyer 1998 October / dpcb1098.iso / Business / Maxim / MAX5 / data.z / ODBCLgin.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-05-10  |  5.5 KB  |  159 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. Attribute VB_Name = "frmODBCLogon"
  103. Attribute VB_GlobalNameSpace = False
  104. Attribute VB_Creatable = False
  105. Attribute VB_PredeclaredId = True
  106. Attribute VB_Exposed = False
  107. '==========================================================================
  108. '  This code and information is provided "as is" without warranty of any
  109. '  kind, either expressed or implied, including but not limited to the
  110. '  implied warranties of merchantability and/or fitness for a particular
  111. '  purpose..
  112. '  Copyright (c) 1998  Multiactive Software Inc.  All Rights Reserved.
  113. '==========================================================================
  114. Option Explicit
  115. Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer
  116. Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
  117. Const SQL_SUCCESS As Long = 0
  118. Const SQL_FETCH_NEXT As Long = 1
  119. Private Sub cmdCancel_Click()
  120.     Unload Me
  121. End Sub
  122. Private Sub cmdOK_Click()
  123. DSN = cboDSNList.Text   'The DSN name
  124. UID = txtUID.Text       'The User Id
  125. PWD = txtPWD.Text       'The password for the database
  126. 'Open the database
  127. Set dbs = OpenDatabase("", False, False, "ODBC;DSN=" & DSN & ";UID=" & UID & ";PWD=" & PWD & ";")
  128.     Load Persform   'Show the form
  129. End Sub
  130. Private Sub Form_Load()
  131.     GetDSNs         'Get all the DSN names from ODBC
  132. End Sub
  133. 'Created by VB
  134. Sub GetDSNs()       'Get all the DSN names from ODBC
  135.     On Error Resume Next
  136.     Dim i As Integer
  137.     Dim sDSNItem As String * 1024
  138.     Dim sDRVItem As String * 1024
  139.     Dim sDSN As String
  140.     Dim sDRV As String
  141.     Dim iDSNLen As Integer
  142.     Dim iDRVLen As Integer
  143.     Dim lHenv As Long         'handle to the environment
  144.     cboDSNList.AddItem "(None)"
  145.     'get the DSNs
  146.     If SQLAllocEnv(lHenv) <> -1 Then
  147.         Do Until i <> SQL_SUCCESS
  148.             sDSNItem = Space(1024)
  149.             i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen)
  150.             sDSN = VBA.Left(sDSNItem, iDSNLen)
  151.                 
  152.             If sDSN <> Space(iDSNLen) Then
  153.                 cboDSNList.AddItem sDSN
  154.             End If
  155.         Loop
  156.     End If
  157.     cboDSNList.ListIndex = 0
  158. End Sub
  159.