Public Function login() As Boolean
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim IdName As String
Form_窗体2.用户名.SetFocus
IdName = Form_窗体2.用户名.text
strSQL = "SELECT * FROM 员工表 WHERE 姓名 = " & IdName
rst.Open strSQL, CurrentProject.Connection, adOpenStatic
If rst.RecordCount > 0 Then
If rst("密码") = Me.密码输入框 Then login = True
End If
End Function
系统提示至少有一个参数未指定
把查询项“姓名“改成ID(长整型)就可以
另立即窗口:
?currentproject.Connection
Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=I:\珠宝数据库\珠宝数据库1.mdb;Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database=D:\PROGRA~1\MICROS~4\Office\SYSTEM.MDW;Jet OLEDB:Registry Path="";Jet OLEDBatabase Password="";Jet OLEDB:Engine Type=5;Jet OLEDBatabase Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDBon't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False
Public Function login() As Boolean
Dim rst As New ADODB.Recordset
Dim strSQL As String
Dim IdName As String
Form_窗体2.用户名.SetFocus
IdName = Form_窗体2.用户名
strSQL = "SELECT * FROM 员工表 WHERE 姓名 = '" & IdName & "'"
rst.Open strSQL, CurrentProject.Connection, adOpenStatic
If rst.RecordCount > 0 Then
If rst("密码") = Me.密码输入框 Then login = True
End If