home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / sql / vbsql / login.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-04-03  |  4.2 KB  |  136 lines

  1. VERSION 2.00
  2. Begin Form login 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "SQL Server Login"
  6.    ForeColor       =   &H00000000&
  7.    Height          =   2640
  8.    Left            =   975
  9.    MaxButton       =   0   'False
  10.    MinButton       =   0   'False
  11.    ScaleHeight     =   2235
  12.    ScaleWidth      =   6720
  13.    Top             =   2055
  14.    Width           =   6840
  15.    Begin TextBox password_field 
  16.       BackColor       =   &H00FFFFFF&
  17.       ForeColor       =   &H00000000&
  18.       Height          =   375
  19.       Left            =   1320
  20.       TabIndex        =   5
  21.       Text            =   "Text1"
  22.       Top             =   1440
  23.       Width           =   3480
  24.    End
  25.    Begin CommandButton CANCEL_BUTTON 
  26.       BackColor       =   &H00C0C0C0&
  27.       Cancel          =   -1  'True
  28.       Caption         =   "Cancel"
  29.       Height          =   480
  30.       Left            =   5160
  31.       TabIndex        =   7
  32.       Top             =   960
  33.       Width           =   1320
  34.    End
  35.    Begin TextBox login_id_field 
  36.       BackColor       =   &H00FFFFFF&
  37.       ForeColor       =   &H00000000&
  38.       Height          =   375
  39.       Left            =   1320
  40.       TabIndex        =   3
  41.       Text            =   "Text1"
  42.       Top             =   840
  43.       Width           =   3480
  44.    End
  45.    Begin CommandButton OK_BUTTON 
  46.       BackColor       =   &H00C0C0C0&
  47.       Caption         =   "OK"
  48.       Default         =   -1  'True
  49.       Height          =   480
  50.       Left            =   5160
  51.       TabIndex        =   6
  52.       Top             =   240
  53.       Width           =   1320
  54.    End
  55.    Begin TextBox Server_name_field 
  56.       BackColor       =   &H00FFFFFF&
  57.       ForeColor       =   &H00000000&
  58.       Height          =   375
  59.       Left            =   1320
  60.       TabIndex        =   1
  61.       Text            =   "Text1"
  62.       Top             =   240
  63.       Width           =   3480
  64.    End
  65.    Begin Label Label3 
  66.       BackColor       =   &H00FFFFFF&
  67.       Caption         =   "&Password:"
  68.       ForeColor       =   &H00000000&
  69.       Height          =   240
  70.       Left            =   120
  71.       TabIndex        =   4
  72.       Top             =   1560
  73.       Width           =   960
  74.    End
  75.    Begin Label Label2 
  76.       BackColor       =   &H00FFFFFF&
  77.       Caption         =   "&Login ID:"
  78.       ForeColor       =   &H00000000&
  79.       Height          =   240
  80.       Left            =   120
  81.       TabIndex        =   2
  82.       Top             =   960
  83.       Width           =   960
  84.    End
  85.    Begin Label Label1 
  86.       BackColor       =   &H00FFFFFF&
  87.       Caption         =   "&Server:"
  88.       ForeColor       =   &H00000000&
  89.       Height          =   240
  90.       Left            =   120
  91.       TabIndex        =   0
  92.       Top             =   360
  93.       Width           =   960
  94.    End
  95. '$INCLUDE: 'VBQUERY.BI'
  96. '$INCLUDE: 'VBDSQL.BI'
  97. Sub CANCEL_BUTTON_Click ()
  98.  Unload Login
  99. End Sub
  100. Sub Form_Load ()
  101.     Server_name_field.Text = DefServer$
  102.     Login_id_field.Text = DefLogin$
  103.     Password_field.Text = ""
  104.     password$ = ""
  105. End Sub
  106. Sub OK_BUTTON_Click ()
  107. Rem Get the server name, login Id, & password from the form
  108.    Servername$ = Server_name_field.Text
  109.    LoginID$ = Login_id_field.Text
  110. Rem Note: Allow a null server name because you may be running on the
  111. Rem same machine as SQL Server.  Allow a null login id because
  112. Rem SQL Server may be running integrated security.
  113. Rem Connect to the server
  114.     If LoginToServer() = SUCCEED Then
  115.         Unload Login
  116.     Else
  117.         Password_field.Text = ""
  118.         password$ = ""
  119.     End If
  120. End Sub
  121. Sub password_field_KeyPress (keyascii As Integer)
  122. Rem This will keep the key from being seen
  123. '   if key pressed is a letter or a number, add it to password and show *
  124. If (keyascii >= 48 And keyascii <= 57) Or (keyascii >= 65 And keyascii <= 90) Or (keyascii >= 97 And keyascii <= 122) Then
  125.     password$ = password$ + Chr$(keyascii)
  126.     keyascii = Asc("*")
  127. ElseIf (keyascii = 8) Then   'if backspace
  128.     If Len(password$) > 0 Then
  129.     password$ = Left$(password$, Len(password$) - 1)
  130.     End If
  131. Else                        'if anything else, throw out
  132.     keyascii = 0
  133.     Beep
  134. End If
  135. End Sub
  136.