home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Buyer 1998 October
/
dpcb1098.iso
/
Business
/
Maxim
/
MAX5
/
data.z
/
ODBCLgin.frm
< prev
next >
Wrap
Text File
|
1998-05-10
|
6KB
|
177 lines
VERSION 5.00
Begin VB.Form frmODBCLogon
BorderStyle = 3 'Fixed Dialog
Caption = "Maximizer ODBC Login"
ClientHeight = 2505
ClientLeft = 2850
ClientTop = 1755
ClientWidth = 4470
ControlBox = 0 'False
Icon = "ODBCLgin.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2505
ScaleWidth = 4470
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton cmdCancel
Cancel = -1 'True
Caption = "&Cancel"
Height = 450
Left = 2520
TabIndex = 7
Top = 1800
Width = 1440
End
Begin VB.CommandButton cmdOK
Caption = "&OK"
Default = -1 'True
Height = 450
Left = 480
TabIndex = 6
Top = 1800
Width = 1440
End
Begin VB.Frame fraStep3
Caption = "Connection Values"
Height = 1455
Index = 0
Left = 120
TabIndex = 8
Top = 120
Width = 4230
Begin VB.TextBox txtUID
Height = 300
Left = 1125
TabIndex = 3
Top = 600
Width = 3015
End
Begin VB.TextBox txtPWD
Height = 300
IMEMode = 3 'DISABLE
Left = 1125
PasswordChar = "*"
TabIndex = 5
Top = 930
Width = 3015
End
Begin VB.ComboBox cboDSNList
Height = 315
ItemData = "ODBCLgin.frx":000C
Left = 1125
List = "ODBCLgin.frx":000E
Sorted = -1 'True
Style = 2 'Dropdown List
TabIndex = 1
Top = 240
Width = 3000
End
Begin VB.Label lblStep3
AutoSize = -1 'True
Caption = "&DSN:"
Height = 195
Index = 1
Left = 135
TabIndex = 0
Top = 285
Width = 390
End
Begin VB.Label lblStep3
AutoSize = -1 'True
Caption = "&User ID:"
Height = 195
Index = 2
Left = 135
TabIndex = 2
Top = 630
Width = 585
End
Begin VB.Label lblStep3
AutoSize = -1 'True
Caption = "&Password:"
Height = 195
Index = 3
Left = 135
TabIndex = 4
Top = 975
Width = 735
End
End
End
Attribute VB_Name = "frmODBCLogon"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'==========================================================================
'
' This code and information is provided "as is" without warranty of any
' kind, either expressed or implied, including but not limited to the
' implied warranties of merchantability and/or fitness for a particular
' purpose..
'
' Copyright (c) 1998 Multiactive Software Inc. All Rights Reserved.
'
'==========================================================================
Option Explicit
Private Declare Function SQLDataSources Lib "ODBC32.DLL" (ByVal henv&, ByVal fDirection%, ByVal szDSN$, ByVal cbDSNMax%, pcbDSN%, ByVal szDescription$, ByVal cbDescriptionMax%, pcbDescription%) As Integer
Private Declare Function SQLAllocEnv% Lib "ODBC32.DLL" (env&)
Const SQL_SUCCESS As Long = 0
Const SQL_FETCH_NEXT As Long = 1
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
DSN = cboDSNList.Text 'The DSN name
UID = txtUID.Text 'The User Id
PWD = txtPWD.Text 'The password for the database
'Open the database
Set dbs = OpenDatabase("", False, False, "ODBC;DSN=" & DSN & ";UID=" & UID & ";PWD=" & PWD & ";")
Load Persform 'Show the form
End Sub
Private Sub Form_Load()
GetDSNs 'Get all the DSN names from ODBC
End Sub
'Created by VB
Sub GetDSNs() 'Get all the DSN names from ODBC
On Error Resume Next
Dim i As Integer
Dim sDSNItem As String * 1024
Dim sDRVItem As String * 1024
Dim sDSN As String
Dim sDRV As String
Dim iDSNLen As Integer
Dim iDRVLen As Integer
Dim lHenv As Long 'handle to the environment
cboDSNList.AddItem "(None)"
'get the DSNs
If SQLAllocEnv(lHenv) <> -1 Then
Do Until i <> SQL_SUCCESS
sDSNItem = Space(1024)
i = SQLDataSources(lHenv, SQL_FETCH_NEXT, sDSNItem, 1024, iDSNLen, sDRVItem, 1024, iDRVLen)
sDSN = VBA.Left(sDSNItem, iDSNLen)
If sDSN <> Space(iDSNLen) Then
cboDSNList.AddItem sDSN
End If
Loop
End If
cboDSNList.ListIndex = 0
End Sub