[ASP]Geeft foutmelding bij aanroep van tweede tabel

Pagina: 1
Acties:
  • 38 views sinds 30-01-2008

  • amiga1260
  • Registratie: Juni 2003
  • Laatst online: 02-05 16:11
Ik krijg deze foutmelding:

ADODB.Recordset (0x800A0CC1)
Item cannot be found in the collection corresponding to the requested name or ordinal.
/Default.asp, line 44

Verder heb ik op allerlei forums gekeken, maar kan geen oplossing voor vinden.

Ik heb twee tabellen:

Studenten
Hobby

In het tabel Hobby heeft als vreemde sleutel Student_ID
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<html>
<title>CodeAve.com(Create XML from Access)</title>
<body bgcolor="#FFFFFF">
<%
' Name of the access db being queried
accessdb="Studenten" 

' Connection string to the access db
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)

' Create a server recordset object
Set rs = Server.CreateObject("ADODB.Recordset")
Set rs2 = Server.CreateObject("ADODB.Recordset")
' Query the states table from the state_info db
sql = "select * from student" 

' Execute the sql
rs.Open sql, cn

' Move to the first record
rs.MoveFirst

' Name for the ouput document 
file_being_created= "student.xml"

' create a file system object
set fso = createobject("scripting.filesystemobject")

' create the text file - true will overwrite any previous files
' Writes the db output to a .xml file in the same directory 
Set act = fso.CreateTextFile(server.mappath(file_being_created), true)

' All non repetitive xml on top goes here
act.WriteLine("<?xml version=""1.0""?>")
act.WriteLine("<Studenten>")

'Loop to output all the query results to the xml document
do while not rs.eof

' counter to give each record a sequential listing
counter=counter+1

Studnr=RS(Student_ID)
act.WriteLine("<Student>")
act.WriteLine("<Voornaam>" & rs("Voornaam") & "</Voornaam>" )
act.WriteLine("<Achternaam>" & rs("Achternaam") & "</Achternaam>" )
act.WriteLine("<Geboortedatum>" & rs("Geboortedatum") & "</Geboortedatum>")

sql2 = "select Hobbynaam from Hobby where [Student_ID]="&Studnr

' Execute the sql
rs2.Open sql2, cn

act.WriteLine("<Hobby's>")
act.WriteLine("<Hobby>" & rs2("Hobbynaam") & "</Hobby>" )
rs2.movenext
loop
act.WriteLine("</Hobby's>")
do while not rs2.eof

act.WriteLine("</Student>")

' move to the next record
rs.movenext
loop

' All non repetitive xml on bottom goes here
act.WriteLine("</Studenten>")


' close the object (xml)
act.close
rs2.close
rs.close

' Writes a link to the newly created xml document in the browser
response.write "<a href='Student.xml'>student</a> (.xml) has been created <br>"
response.write "on " & now() & "<br>"
%>
</body>
</html>


Het sript moet het volgende doen:

De gegevens uit het Tabel Studenten, voornaam, achternaam en geboortedatum ophalen.

Uit het Tabel Hobby, de hobby's van de studenten halen.

Deze gegevens moeten dan in een XML bestand worden weggeschreven.

  • Jaspertje
  • Registratie: September 2001
  • Laatst online: 18-05 15:53

Jaspertje

Max & Milo.. lief

rs("studentID")

Haakjes, toch wel erg makkelijk hoor..... Deze fout betekend altijd dat je iets aanroept wat niet in je SQL statement staat

Zoek ff met google anders:
http://www.google.nl/sear...requested+name+or+ordinal

[ Voor 122% gewijzigd door Jaspertje op 11-06-2004 15:36 ]


  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 12:49

gorgi_19

Kruimeltjes zijn weer op :9

Sterker nog, ik heb destijds een ASP-FAQ geschreven waar dit probleem netjes in beschreven staat. Zie klik

Zie voor je volgende topics ook P&W FAQ - De "quickstart" ; 82 regels code zijn niet allemaal relevant; hetprobleem is terug te brengen naar 5 regels.

[ Voor 34% gewijzigd door gorgi_19 op 11-06-2004 15:37 ]

Digitaal onderwijsmateriaal, leermateriaal voor hbo


Dit topic is gesloten.