'connect sql server 2000
'-----------------------------------
Private Sub Command1_Click()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim connect As String
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
Private Sub Command1_Click()
Dim sql As String
Dim Rst As New ADODB.Recordset
If txtuser.Text = "" Then
MsgBox "对不起,没有这个用户!", vbOKOnly + vbExclamation, ""
txtuser.SetFocus
Else
sql = "select * from employee where 用户名='" & txtuser.Text & "'"
Rst.Open sql, conn, adOpenKeyset, adLockPessimistic
If Rst.EOF = True Then
MsgBox "对不起,该用户不存在", vbOKOnly + vbExclamation, ""
txtuser.SetFocus
Else
If Rst.Fields(1) = txtpwd.Text Then
userID = txtuser.Text
userpow = Rst.Fields(2)
Rst.Close
Unload Me
Form1.Show
Else
MsgBox "密码不正确", vbOKOnly + vbExclamation, ""
txtpwd.SetFocus
End If
End If
End If
cnt = cnt + 1
If cnt = 3 Then
Unload Me
End If
Exit Sub
End Sub
Private Sub Form_Load()
login.Top = (Screen.Height - login.Height) / 2
login.Left = (Screen.Width - login.Width) / 2
Dim connectionstring As String
connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\hospital.mdb;Persist Security Info=False"
conn.Open connectionstring
cnt = 0
End Sub
Private Sub Picture1_Click()
End Sub
Private Sub Txtpwd_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
Command1.SetFocus
End If
End Sub
Private Sub txtuser_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then
txtpwd.SetFocus
End If
End Sub