insert_namehere
08-22-2008, 02:40 PM
Hello all - I have a relatively simple question about what I'm sure is a relatively simple problem, but I've been wrestling with it for hours and getting nowhere!
I have a database with around 45 tables in it. They all carry a column called "StudentID". When I do a simple single JOIN such as:
Set con = Server.CreateObject("ADODB.connection")
Set rs = Server.CreateObject("ADODB.recordset")
con.open(application("bugCon"))
strSQL = "SELECT First_Name, Last_Name, para.classno FROM StudentRecord JOIN para ON (StudentRecord.StudentID = para.StudentID) WHERE StudentRecord.StudentID = '1095'"
Set rs = con.execute(strSQL)
do while NOT rs.EOF
Name = rs("First_Name") &" "& rs("Last_Name")
Course = rs("classno") &"<br>"
rs.MoveNext
Loop
response.write(Name &"<HR>")
response.write(Course)
set con = nothing
set rs = nothing
set strSQL = nothing
it works fine.
However, when I write a multiple join such as:
Set con = Server.CreateObject("ADODB.connection")
Set rs = Server.CreateObject("ADODB.recordset")
con.open(application("bugCon"))
'"SELECT StudentRecord.First_Name, StudentRecord.Last_Name, para.classno FROM StudentRecord INNER JOIN para ON StudentRecord.StudentID = para.StudentID INNER JOIN CISMG ON CISMG.StudentID = StudentRecord.StudentID Where StudentRecord.StudentID = '1095' GROUP BY StudentRecord.First_Name, StudentRecord.Last_Name, para.classno"
strSQL = "SELECT First_Name, Last_Name, para.classno, CISMG.classno FROM StudentRecord JOIN para ON (StudentRecord.StudentID = para.StudentID) Left JOIN CISMG ON (CISMG.StudentID = StudentRecord.StudentID) WHERE StudentRecord.StudentID = '1095'"
Set rs = con.execute(strSQL)
Name = rs("First_Name") &" "& rs("Last_Name")
do while NOT rs.EOF
Course1 = rs("para.classno") &"<br>"
Course2 = rs("CISMG.classno") &"<br>"
rs.MoveNext
Loop
response.write(Name &"<HR>")
response.write(Course)
set con = nothing
set rs = nothing
set strSQL = nothing
I get the following error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
/database/multijoin.asp, line 16
WHAT am I doing wrong!!
Thanks in advance, your friendly neighborhood idiot.
I have a database with around 45 tables in it. They all carry a column called "StudentID". When I do a simple single JOIN such as:
Set con = Server.CreateObject("ADODB.connection")
Set rs = Server.CreateObject("ADODB.recordset")
con.open(application("bugCon"))
strSQL = "SELECT First_Name, Last_Name, para.classno FROM StudentRecord JOIN para ON (StudentRecord.StudentID = para.StudentID) WHERE StudentRecord.StudentID = '1095'"
Set rs = con.execute(strSQL)
do while NOT rs.EOF
Name = rs("First_Name") &" "& rs("Last_Name")
Course = rs("classno") &"<br>"
rs.MoveNext
Loop
response.write(Name &"<HR>")
response.write(Course)
set con = nothing
set rs = nothing
set strSQL = nothing
it works fine.
However, when I write a multiple join such as:
Set con = Server.CreateObject("ADODB.connection")
Set rs = Server.CreateObject("ADODB.recordset")
con.open(application("bugCon"))
'"SELECT StudentRecord.First_Name, StudentRecord.Last_Name, para.classno FROM StudentRecord INNER JOIN para ON StudentRecord.StudentID = para.StudentID INNER JOIN CISMG ON CISMG.StudentID = StudentRecord.StudentID Where StudentRecord.StudentID = '1095' GROUP BY StudentRecord.First_Name, StudentRecord.Last_Name, para.classno"
strSQL = "SELECT First_Name, Last_Name, para.classno, CISMG.classno FROM StudentRecord JOIN para ON (StudentRecord.StudentID = para.StudentID) Left JOIN CISMG ON (CISMG.StudentID = StudentRecord.StudentID) WHERE StudentRecord.StudentID = '1095'"
Set rs = con.execute(strSQL)
Name = rs("First_Name") &" "& rs("Last_Name")
do while NOT rs.EOF
Course1 = rs("para.classno") &"<br>"
Course2 = rs("CISMG.classno") &"<br>"
rs.MoveNext
Loop
response.write(Name &"<HR>")
response.write(Course)
set con = nothing
set rs = nothing
set strSQL = nothing
I get the following error:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.
/database/multijoin.asp, line 16
WHAT am I doing wrong!!
Thanks in advance, your friendly neighborhood idiot.