0
請你幫我明白了什麼,毛病下面的代碼:訪問VBA - 數據提供程序或其他服務返回E_FAIL狀態
Private Function FillCalendar()
Dim cnn As ADODB.Connection
Dim ssql As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Set cnn = CurrentProject.Connection
Dim i As Integer
Dim Records As Integer
ssql = "SELECT Format(Availability.AvailabilityDate,'mmm dd ddd') AS MyDate FROM Availability WHERE HotelId=3 AND Month(Availability.AvailabilityDate)=Month(Now()) GROUP BY Availability.AvailabilityDate"
rst.CursorLocation = adUseClient
rst.Open ssql, cnn
Records = rst.RecordCount
For i = 1 To Records
Me("Text" & i).Visible = True
Me("Text" & i).Value = rst.Fields!MyDate
If InStr(Me("Text" & i).Value, "sat") Or InStr(Me("Text" & i).Value, "sun") Then
Me("Text" & i).BackColor = RGB(179, 45, 0)
Else
Me("Text" & i).BackColor = RGB(0, 114, 188)
End If
rst.MoveNext
Next i
rst.Close
Set rst = Nothing
End Function
在代碼stucks 紀錄= rst.RecordCount,不能找出原因。 我叫可用性表是非常簡單的:
- AvailabilityId自動編號長整型(主鍵)
- RoomTypeId號(外鍵)
- HotelId號(外鍵)
- AvailabilityDate日期/時間(格式:ShortDate)
- AvailableRooms號(長整型 - 默認值:0)
謝謝很多提前
非常感謝,但它仍然顯示錯誤。現在,代碼在if rst.EOF = false處得到。然後 – Kurt