1
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雖然數據庫中的數據的一個爲什麼recordCount不適用於我的代碼?
光標類型會影響RecordCount與特定連接一樣多。您可能需要閱讀以下內容:https://msdn.microsoft.com/zh-cn/library/ms676701(v=vs.85).aspx – Ralph
謝謝!它的工作,我只是使用cursorType的adOpenStatic –