Avatar billede ravnkilde Nybegynder
11. oktober 2007 - 13:21 Der 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;"

--- kode stop ---
Avatar billede w13 Novice
11. oktober 2007 - 13:23 #1
Du gemmer ParticipantID i Participants_ParticipantID, så hvis du nu prøver at rette linje 114 til:

act.WriteLine("<td align=""right"">"&objRs("Participants_ParticipantID")&"</td>" )
Avatar billede softspot Forsker
11. oktober 2007 - 13:56 #2
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... :-)
Avatar billede softspot Forsker
11. oktober 2007 - 14:02 #3
Det jeg taler om ser sådan ud:

strSQL= "SELECT p.ParticipantID, " & _
  "p.Firstname, " & _
  "p.Familyname, " & _
  "p.Function, " & _
  "p.Department, " & _
  "p.Country, " & _
  "p.Mobilephone, " & _
  "p.Email, " & _
  "p.Registrationdate, " & _
  "ad.ArrivalDate, " & _
  "ad.ArrivalMonth, " & _
  "ad.ArrivalHour, " & _
  "ad.ArrivalMinute, " & _
  "ad.ArrivalBy, " & _
  "ad.ArrivalFlightNo, " & _
  "ad.TransferToHotel, " & _
  "dd.DepartureDate, " & _
  "dd.DepartureMonth, " & _
  "dd.DepartureHour, " & _
  "dd.DepartureMinute, " & _
  "dd.DepartureBy, " & _
  "dd.DepartureFlightNo, " & _
  "dd.TransferToAirport, " & _
  "rr.RoomRequired, " & _
  "rr.CheckinDate, " & _
  "rr.CheckinMonth, " & _
  "rr.CheckoutDate, " & _
  "rr.CheckoutMonth, " & _
  "rr.RoomPreference, " & _
  "rr.DiateryRemarks, " & _
  "rr.DiateryPreferences " & _
  "FROM ((Participants p INNER JOIN " & _
      "DepartureDetails dd ON p.ParticipantID = dd.ParticipantID) " & _
    "INNER JOIN RoomReservation rr ON p.ParticipantID = rr.ParticipantID) " & _
  "INNER JOIN ArrivalDetails ad ON p.ParticipantID = ad.ParticipantID " & _
  "ORDER BY p.Familyname;"
Avatar billede ravnkilde Nybegynder
11. oktober 2007 - 14:11 #4
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!
Avatar billede w13 Novice
11. oktober 2007 - 14:22 #5
Svar =)
Avatar billede softspot Forsker
11. oktober 2007 - 14:33 #6
Ja, man skal bruge de hjælpemidler man kan komme i nærheden af og som gør opgaven lettere... :-)
Avatar billede softspot Forsker
12. oktober 2007 - 10:34 #7
Tak for point :)
Avatar billede w13 Novice
12. oktober 2007 - 13:44 #8
Takker!
Avatar billede Ny bruger Nybegynder

Din løsning...

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester