![]() |
#2
风吹过b2016-08-30 19:37
|

Private Sub cmdok_Click()
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from 账户 where 用户名='" + Text1.Text + "'and 密码= '" + Text2.Text + "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
Dim MyComp1 As Integer
MyComp1 = StrComp(rs1.Fields("密码"), Text2.Text, vbBinaryCompare)
If MyComp1 <> 0 Then
MsgBox "请输入正确的大小写字母!", , Me.Caption
Exit Sub
End If
Load Form3
Form3.Show
Unload Me
Else
MsgBox "用户名或密码不正确,请重新输入!", , Me.Caption
End If
rs1.Close
End Sub
Dim rs1 As New ADODB.Recordset
rs1.Open "select * from 账户 where 用户名='" + Text1.Text + "'and 密码= '" + Text2.Text + "'", cnn, adOpenKeyset, adLockOptimistic
If rs1.RecordCount > 0 Then
Dim MyComp1 As Integer
MyComp1 = StrComp(rs1.Fields("密码"), Text2.Text, vbBinaryCompare)
If MyComp1 <> 0 Then
MsgBox "请输入正确的大小写字母!", , Me.Caption
Exit Sub
End If
Load Form3
Form3.Show
Unload Me
Else
MsgBox "用户名或密码不正确,请重新输入!", , Me.Caption
End If
rs1.Close
End Sub
rs1.Open "select * from 账户 where 用户名='" + Text1.Text + "'and 密码= '" + Text2.Text + "'", cnn, adOpenKeyset, adLockOptimistic
MyComp1 = StrComp(rs1.Fields("密码"), Text2.Text, vbBinaryCompare)
这2句是什么意思,请大神帮我翻译一下。
还有个问题,第一个代码就是正常的,第二个代码我是抄某大神的,他上面用正常,放到我的工程里就不行了,这个是为什么
第一个

Private Sub Form_Load()
cnn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\账户.mdb"
Text1.Text = ""
Text2.Text = ""
Me.Show
Text1.SetFocus '窗体加载时,用户名文本框获得焦点
End Sub
cnn.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.Path & "\账户.mdb"
Text1.Text = ""
Text2.Text = ""
Me.Show
Text1.SetFocus '窗体加载时,用户名文本框获得焦点
End Sub
第二个
Private Sub Form_Active()
'窗体加载时,用户名文本框获得焦点
Text1.SetFocus
End Sub
'窗体加载时,用户名文本框获得焦点
Text1.SetFocus
End Sub
[此贴子已经被作者于2016-8-30 18:05编辑过]