Dim rec As ADODB.Recordset Dim cnn As ADODB.Connection Dim sq1 As StringSet cnn = New ADODB.Connection cnn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=路桥收费;Data Source=HUST"sq1 = "select distinct 收费员 from 收费员" Set rec = cnn.Execute(sq1)While Not rec.EOF txtUserName.AddItem (rec("收费员")) rec.MoveNext Wend txtUserName.ListIndex = 0 Dim sBuffer As String Dim lSize As Long sBuffer = Space$(255) lSize = Len(sBuffer) Call GetUserName(sBuffer, lSize) If lSize > 0 Then txtUserName.Text = ""
Else txtUserName.Text = vbNullString End If OK = False miCount = 0 End SubPrivate Sub cmdCancel_Click() OK = False Me.Hide
End Sub Private Sub cmdOK_Click()Dim rec As ADODB.Recordset Dim cnn As ADODB.Connection Set cnn = New ADODB.Connection cnn.Open "DSN=收费系统DSN;UID=sa;PWD=2212;" cnn.CursorLocation = adUseClient Dim txtSQL As String Dim mrc As ADODB.Recordset Dim MsgText As String
UserName = "" If Trim(txtUserName.Text = "") Then MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告" txtUserName.SetFocus Else txtSQL = "select * from 收费员 where 收费员= '" & txtUserName.Text & "'" Set mrc = cnn.Execute(txtSQL, MsgText) If mrc.EOF = True Then MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告" txtUserName.SetFocus Else If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then OK = True mrc.Close Me.Hide UserName = Trim(txtUserName.Text)
'txtpower.Text = Trim(mrc.Fields(2)) Else MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告" txtPassword.SetFocus txtPassword.Text = "" End If End If End If
Dim cnn As ADODB.Connection
Dim sq1 As StringSet cnn = New ADODB.Connection
cnn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=路桥收费;Data Source=HUST"sq1 = "select distinct 收费员 from 收费员"
Set rec = cnn.Execute(sq1)While Not rec.EOF
txtUserName.AddItem (rec("收费员"))
rec.MoveNext
Wend
txtUserName.ListIndex = 0
Dim sBuffer As String
Dim lSize As Long
sBuffer = Space$(255)
lSize = Len(sBuffer)
Call GetUserName(sBuffer, lSize)
If lSize > 0 Then
txtUserName.Text = ""
Else
txtUserName.Text = vbNullString
End If
OK = False
miCount = 0
End SubPrivate Sub cmdCancel_Click()
OK = False
Me.Hide
End Sub
Private Sub cmdOK_Click()Dim rec As ADODB.Recordset
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
cnn.Open "DSN=收费系统DSN;UID=sa;PWD=2212;"
cnn.CursorLocation = adUseClient
Dim txtSQL As String
Dim mrc As ADODB.Recordset
Dim MsgText As String
UserName = ""
If Trim(txtUserName.Text = "") Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
txtSQL = "select * from 收费员 where 收费员= '" & txtUserName.Text & "'"
Set mrc = cnn.Execute(txtSQL, MsgText)
If mrc.EOF = True Then
MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "警告"
txtUserName.SetFocus
Else
If Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
OK = True
mrc.Close
Me.Hide
UserName = Trim(txtUserName.Text)
'txtpower.Text = Trim(mrc.Fields(2))
Else
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告"
txtPassword.SetFocus
txtPassword.Text = ""
End If
End If
End If
加上txtUserName.clear