帮我看看吧!!!

jimmychen1981 2003-04-06 11:54:14
Private Sub cmdOK_Click()
If Trim(cboUsername.Text) <> "" Then
UserRst.MoveFirst
'在myRecordset中找出与用户名组合框中显示的用户名相符的一条记录信息
UserRst.Find "用户名='" & cboUsername.Text & "'"
'判断是否存在该用户名
If UserRst.EOF = False Then
'判断此条记录中的"密码"字段信息与密码框中的写入信息是否相同,并且屏蔽了大小写以及有无空格的区别
If UCase(Trim(UserRst.Fields("密码").Value)) <> UCase(Trim(txtPassword.Text)) Then
MsgBox "密码或用户名有误,请重新输入!", vbExclamation, "提示"
txtPassword = ""
txtPassword.SetFocus
Else
Username = cboUsername.Text
Me.Hide
frmMain.Show
End If
Else
MsgBox "该用户名不存在,请重新输入!", vbExclamation, "警告"
cboUsername.SetFocus
End If
Else
MsgBox "用户名不可为空值,请重新输入!", vbExclamation, "提示"
cboUsername.SetFocus
End If
End Sub
为什么“If UserRst.EOF = False Then”这个语句可以判断出UserRst记录集中是否存在cboUsername.Text 中显示的用户名呢?还有到底find的用法是怎么样的呢?请不吝赐教!!谢谢!!
...全文
29 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
阿甘 2003-04-06
MSDN里的Find

Find Method

Searches a Recordset for the record that satisfies the specified criteria. If the criteria is met, the recordset position is set on the found record; otherwise, the position is set on the end of the recordset.

Syntax

Find (criteria, SkipRows, searchDirection, start)

Parameters

criteria A String containing a statement that specifies the column name, comparison operator, and value to use in the search.

SkipRows An optional Long value, whose default value is zero, that specifies the offset from the current row or start bookmark to begin the search.

searchDirection An optional SearchDirectionEnum value that specifies whether the search should begin on the current row or the next available row in the direction of the search. Its value can be adSearchForward or adSearchBackward. The search stops at the start or end of the recordset, depending on the value of searchDirection.

start An optional Variant bookmark to use as the starting position for the search.

Remarks

The comparison operator in criteria may be ">" (greater than), "<" (less than), "=" (equal), ">=" (greater than or equal), "<=" (less than or equal), "<>" (not equal), or "like" (pattern matching).

The value in criteria may be a string, floating point number, or date. String values are delimited with single quotes (for example, "state = 'WA'"). Date values are delimited with "#" (number sign) marks (for example, "start_date > #7/22/97#").

If the comparison operator is "like", the string value may contain "*" (one or more occurrences of any character) or "_" (one occurrence of any character). (For example, "state like M_*" matches Maine and Massachusetts.)
回复
阿甘 2003-04-06
Sorry ,没看全程序

使用find方法,当recordset里面存在符合条件(find的第一个参数)的记录的时候
该recordset的pos指针就指向首条符合条件的记录
否则指针就到recordset的结尾,即UserRst.EOF=true
回复
阿甘 2003-04-06
能得到记录,当然就有该用户存在啦

关键的信息是之前的数据库查询语句(select ……)
回复
相关推荐
发帖

1187

社区成员

VB 数据库(包含打印,安装,报表)
申请成为版主
帖子事件
创建了帖子
2003-04-06 11:54
社区公告
暂无公告