このコードを機能させようとしていますが、RecordCount に対して -1 を返し続けます。selectステートメントは値を見つけます。私はデータベースに行き、そこで実行しました。しかし、プログラムで値を取得できません。
Dim quotedPubs As ADODB.Connection
Set quotedPubs = New ADODB.Connection
quotedPubs.Open "PROVIDER=SQLOLEDB; DATA SOURCE=*****;INITIAL CATALOG=*****; User ID=****; Password=****"
Dim hoursPubs As ADODB.Connection
Set hoursPubs = New ADODB.Connection
hoursPubs.Open "PROVIDER=SQLOLEDB; DATA SOURCE=*****;INITIAL CATALOG=*****; User ID=****; Password=****"
Dim lsPubs As ADODB.Recordset
Set lsPubs = New ADODB.Recordset
With lsPubs
.ActiveConnection = quotedPubs
.Open "SELECT ProjectNumber FROM hours h"
' WHERE h.lead = " & sEmpNum & ""
If (lsPubs.RecordCount > 0) Then
arr = lsPubs.GetRows(lsPubs.RecordCount)
.Close