终于发现问题了
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
conn.C
conn.ConnectionTimeout = 30
conn.Open
rs.Open "select user_id,user_password from userdata where user_id='" & Trim(TxtNum.Text) & "' And user_password='" & Trim(TxtPassword.Text) & "'", conn, adOpenStatic, adLockReadOnly, adCmdText
If rs.EOF = True And rs.BOF Then
m = MsgBox("请重新登录", vbExclamation)
Else
userName = rs.Fields("user_name").Value
……
这样写还是提示 rs.Fields("user_name").Value为空值
但是把
里面
rs.Open "select user_id,user_password from userdata where user_id='" & Trim(TxtNum.Text) & "' And user_password='" & Trim(TxtPassword.Text) & "'", conn, adOpenStatic, adLockReadOnly, adCmdText
改为
rs.Open "select user_id,user_password,user_name from userdata where user_id='" & Trim(TxtNum.Text) & "' And user_password='" & Trim(TxtPassword.Text) & "'", conn, adOpenStatic, adLockReadOnly, adCmdText