Public Function cekUsername(ByVal usr As String) As Boolean
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set rs.ActiveConnection = CurrentProject.Connection
rs.Open "SELECT * FROM pengguna WHERE username='" & usr & "';"
If rs.RecordCount = 1 Then
cekUsername = True
Else
cekUsername = False
End If
rs.Close
Set rs = Nothing
End Function
它始终返回false虽然数据库中有一个数据
答案 0 :(得分:1)
你必须使用
rs.MoveLast
在使用RecordCount之前,否则会显示错误的值