11. oktober 2007 - 13:21Der er
6 kommentarer og 2 løsninger
ADODB.Recordset fejlmeddelelse
På nedenstående kode får jeg fejlmeddelelsen: ADODB.Recordset (0x800A0CC1) Item cannot be found in the collection corresponding to the requested name or ordinal. create_xls.asp, line 114
Linie 114 ser sådan her ud: act.WriteLine("<td align=""right"">" & objRs("ParticipantID") & "</td>" )
ParticipantID findes med sikkerhed i tabellen "Particpants".
Hvad er der galt? Hvis jeg udskriver min SQL - og samtidig - blænder linie 114 af, ser SQL'en helt fint ud.
--- kode start ---
strSQL= "SELECT Participants.ParticipantID AS Participants_ParticipantID, Participants.Firstname, Participants.Familyname, Participants.Function, Participants.Department, Participants.Country, Participants.Mobilephone, Participants.Email, Participants.Registrationdate, ArrivalDetails.ArrivalDate, ArrivalDetails.ArrivalMonth, ArrivalDetails.ArrivalHour, ArrivalDetails.ArrivalMinute, ArrivalDetails.ArrivalBy, ArrivalDetails.ArrivalFlightNo, ArrivalDetails.TransferToHotel, DepartureDetails.DepartureDate, DepartureDetails.DepartureMonth, DepartureDetails.DepartureHour, DepartureDetails.DepartureMinute, DepartureDetails.DepartureBy, DepartureDetails.DepartureFlightNo, DepartureDetails.TransferToAirport, RoomReservation.RoomRequired, RoomReservation.CheckinDate, RoomReservation.CheckinMonth, RoomReservation.CheckoutDate, RoomReservation.CheckoutMonth, RoomReservation.RoomPreference, RoomReservation.DiateryRemarks, RoomReservation.DiateryPreferences FROM ((Participants INNER JOIN DepartureDetails ON Participants.ParticipantID = DepartureDetails.ParticipantID) INNER JOIN RoomReservation ON Participants.ParticipantID = RoomReservation.ParticipantID) INNER JOIN ArrivalDetails ON Participants.ParticipantID = ArrivalDetails.ParticipantID ORDER BY Participants.Familyname;"
Men hvorfor giver du overhovedet ParticipantID et alias, det er tilsyneladende ikke nødvendigt...?
En anden ting der kan være med til at gøre dine SQL-sætninger lettere at overskue (specielt når du JOIN'er) er at give tabellerne et kort alias. Ud over det så kan du bruge linie-separatoren (underscore, dvs. _) til at dele strengen op. Det kan godt være det er lidt træls når du skal sidde og skrive koden, men du bliver glad for det, når du skal rette i koden... :-)
God pointe, softspot! Jeg har "snydt" ved at lade Access generere SQL'en - og den bruger åbenbart det, du kalder alias (Participants.ParticipantID AS Participants_ParticipantID). Læg et svar begge for jeres bidrag. PS: Det virker nu!
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.