Reply
Retrieve data from two table
Old 11-18-2004, 01:28 PM Retrieve data from two table
barbara's Avatar
Skilled Talker

Posts: 79
Trades: 0
I am trying to retrieve from two table based on matching id and display data in a table.

here's my code:

<%@ Language = VBScript%>
<html>
<head>
<%
set conn=server.createobject("adodb.connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/inetpub/wwwroot/database/HTC.mdb"

SQL = "select ID, CompanyName, ContactName, WhichTest, Description, Sample, Sample2, Sample3, Sample4, Sample5, Sample6, AbrasionHeadNo, TestMethod, Notes from tblCustomers, tblAbrasions where ID = CustID"
Set rs=conn.execute(SQL)
%>


<TABLE BORDER=1>
<TR>
<%

' Loop through each Field, printing out the Field Names

For i = 0 to objrs.fields.count - 1
%>
<TD><% = objrs(i).name %></TD>
<% next %>
</TR>
<%

' Loop through rows, displaying each field

while not objrs.eof
%>
<TR>
<% For i = 0 to objrs.fields.count - 1
%>
<TD VALIGN=TOP><% = objrs(i) %></TD>
<% Next %>

</TR>
<%
objrs.MoveNext

wend

objrs.Close
conn.close
%>

I got this error message:

Microsoft VBScript runtime (0x800A01A8)
Object required: ''
/project/report-sample.asp, line 22 (which is this line: For i = 0 to objrs.fields.count - 1 )

was my code incorrect?

thanks
barbara is offline
Reply With Quote
View Public Profile
 
 
When You Register, These Ads Go Away!
Old 11-18-2004, 01:45 PM
Anacrusis's Avatar
Defies a Status

Posts: 2,099
Name: Adam
Location: Colchester CT
Trades: 0
Your creating a recordset and calling it "rs" - Set rs=conn.execute(SQL)
your then trying to reference a recordset called "objrs" - objrs.fields.count

You need to pick one name and stick with it.
Anacrusis is offline
Reply With Quote
View Public Profile
 
Old 11-18-2004, 02:40 PM
barbara's Avatar
Skilled Talker

Posts: 79
Trades: 0
thanks.
barbara is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Retrieve data from two table
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10954 seconds with 13 queries