Caption = "Read Only (not supported by all Drivers)"
Height = 252
Left = 360
TabIndex = 4
Top = 1560
Width = 3996
End
Begin TextBox cUserName
Height = 288
Left = 1560
TabIndex = 2
Top = 840
Width = 2772
End
Begin TextBox cPassword
Height = 288
Left = 1560
PasswordChar = "*"
TabIndex = 3
Top = 1200
Width = 2772
End
Begin CommandButton OkayButton
Caption = "&Open"
Default = -1 'True
Height = 372
Left = 360
TabIndex = 5
Top = 1896
Width = 1572
End
Begin CommandButton CancelButton
Cancel = -1 'True
Caption = "&Cancel"
Height = 372
Left = 2520
TabIndex = 6
Top = 1896
Width = 1572
End
Begin Label DataBaseLabel
Caption = "DataBase:"
Height = 249
Left = 120
TabIndex = 10
Top = 474
Width = 1339
End
Begin Label DBNameLabel
Caption = "Source/Server:"
Height = 249
Left = 120
TabIndex = 7
Top = 118
Width = 1460
End
Begin Label UserNameLabel
Caption = "User ID:"
Height = 249
Left = 120
TabIndex = 8
Top = 842
Width = 1339
End
Begin Label PasswordLabel
Caption = "Password:"
Height = 249
Left = 120
TabIndex = 9
Top = 1186
Width = 1339
End
Option Explicit
'ODBC.DLL APIs
Declare Function SQLAllocEnv Lib "odbc.dll" (env As Long) As Integer
Declare Function SQLDataSources Lib "ODBC.DLL" (ByVal henv As Long, ByVal fdir As Integer, ByVal szDSN As String, ByVal cbDSNMAx As Integer, pcbDSN As Integer, ByVal szDesc As String, ByVal cbDescMax As Integer, pcbDesc As Integer) As Integer
Sub CancelButton_Click ()
gfDBOpenFlag = False
Unload Me
End Sub
Sub cDBName_Click ()
Dim tmp As String
Dim x As Integer
cDatabase = ""
cUserName = ""
cPassword = ""
'get the database name if there is one
tmp = String$(255, 32)
x = OSGetPrivateProfileString(cDBName, "database", "", tmp, Len(tmp), "ODBC.INI")
cDatabase = Mid$(tmp, 1, x)
'get the last user name is there is one
tmp = String$(255, 32)
x = OSGetPrivateProfileString(cDBName, "lastuser", "", tmp, Len(tmp), "ODBC.INI")
cUserName = Mid$(tmp, 1, x)
cPassword = ""
If cUserName <> "" Then cPassword.SetFocus
End Sub
Sub cDBName_LostFocus ()
Call cDBName_Click
End Sub
Sub Form_Load ()
cDBName = gstDBName
cDatabase = gstDatabase
cUserName = gstUserName
cPassword = gstPassword
Left = (Screen.Width - Width) / 2
GetDataSources cDBName
MsgBar "Enter DataBase Parameters", False
End Sub
Sub Form_Unload (Cancel As Integer)
MsgBar "", False
End Sub
'this routine fills a list box with all available
'ODBC data sources found in ODBC.INI
Sub GetDataSources (listctrl As Control)
Dim DataSource As String, Description As String
Dim DataSourceLen As Integer, DescriptionLen As Integer