hie hi...it's me again..i almost finish my system..=)
juz a minor problem..i guess..
is about the SQL to join tables, let explain my situation 1st..
i hv 3 tables here, LOAN, TRANSACTION, PRODUCT
TRANSACTION is the composite entity which relates LOAN and PRODUCT.
now i wan to get data from LOAN and PRODUCT.
my code:
Set rs_1 = Server.CreateObject("ADODB.Recordset"
SQL_1="SELECT company.company_name , loan.loan_id AS loan_id, loan.loan_date, loan.due_date FROM company, loan WHERE company.company_id=loan.company_id AND loan_id = '"&LoanID&"' "
Set rs_1 = MyDB.execute(ReturnSQL_1)
LID=rsReturn_1("loan_id"
Set rsReturn = Server.CreateObject("ADODB.Recordset"
ReturnSQL="SELECT product.product_name FROM product, transaction WHERE product.product_id=transaction.product_id AND loan_id ="& LID & ""
Set rsReturn = MyDB.execute(ReturnSQL)
%>
<form >
<TABLE >
<TR >
</TR>
<% While Not rs_1.EOF %>
<TR>
<TD width="150"><font face="Century Gothic" size="3">
<% Response.Write rs_1("loan_id"
%>
</font></TD>
<TD><font face="Century Gothic" size="3">
<% Response.Write rs_1("company_name"
%>
</font></TD>
<TD><font face="Century Gothic" size="3">
<% Response.Write rs_1("loan_date"
%>
</font></TD>
<TD><font face="Century Gothic" size="3">
<% Response.Write r_1("due_date"
%>
</font></TD>
***** here's my problems*****
<%If Not rsReturn.EOF Then%>
<%While Not rsReturn.EOF %>
<TD>
<font face="Century Gothic" size="3">
Response.Write rsReturn("product_name"
%>
</font>
</TD> <% rsReturn.MoveNext
'Wend
%>
<%Else%>
<TD><font face="Century Gothic" size="3"><b><font color="#FF0000">No Item</font></b>
</font></TD>
<%'nd If%>
</TR>
<%
rsReturn_1.MoveNext
Wend
rsReturn.Close
rsReturn_1.Close
MyDB.Close
Set rsReturn = Nothing
Set rsReturn_1 = Nothing
Set MyDB = Nothing
%>
<TR>
<TD colspan="4" width="150"> <br>
<table width="300 ">
<tr>
<td><font size="3"><b><font face="Century Gothic" color="#FF0000">Please
enter the Loan Form No.</font></b></font>
<br><br>
<input type="text" name="LoanID">
<input type="submit" name="Submit" value="GO!!">
</td></tr>
</table>
</TD></TR>
</Table>
</form>
***** Questions ********
we can't have 2 "while" function in the codes right..but i hv 2 recordsets...how can i solve this situation?..i need to loop both the recordset...
How?
juz a minor problem..i guess..
is about the SQL to join tables, let explain my situation 1st..
i hv 3 tables here, LOAN, TRANSACTION, PRODUCT
TRANSACTION is the composite entity which relates LOAN and PRODUCT.
now i wan to get data from LOAN and PRODUCT.
my code:
Set rs_1 = Server.CreateObject("ADODB.Recordset"
SQL_1="SELECT company.company_name , loan.loan_id AS loan_id, loan.loan_date, loan.due_date FROM company, loan WHERE company.company_id=loan.company_id AND loan_id = '"&LoanID&"' "
Set rs_1 = MyDB.execute(ReturnSQL_1)
LID=rsReturn_1("loan_id"
Set rsReturn = Server.CreateObject("ADODB.Recordset"
ReturnSQL="SELECT product.product_name FROM product, transaction WHERE product.product_id=transaction.product_id AND loan_id ="& LID & ""
Set rsReturn = MyDB.execute(ReturnSQL)
%>
<form >
<TABLE >
<TR >
</TR>
<% While Not rs_1.EOF %>
<TR>
<TD width="150"><font face="Century Gothic" size="3">
<% Response.Write rs_1("loan_id"
</font></TD>
<TD><font face="Century Gothic" size="3">
<% Response.Write rs_1("company_name"
</font></TD>
<TD><font face="Century Gothic" size="3">
<% Response.Write rs_1("loan_date"
</font></TD>
<TD><font face="Century Gothic" size="3">
<% Response.Write r_1("due_date"
</font></TD>
***** here's my problems*****
<%If Not rsReturn.EOF Then%>
<%While Not rsReturn.EOF %>
<TD>
<font face="Century Gothic" size="3">
Response.Write rsReturn("product_name"
</font>
</TD> <% rsReturn.MoveNext
'Wend
%>
<%Else%>
<TD><font face="Century Gothic" size="3"><b><font color="#FF0000">No Item</font></b>
</font></TD>
<%'nd If%>
</TR>
<%
rsReturn_1.MoveNext
Wend
rsReturn.Close
rsReturn_1.Close
MyDB.Close
Set rsReturn = Nothing
Set rsReturn_1 = Nothing
Set MyDB = Nothing
%>
<TR>
<TD colspan="4" width="150"> <br>
<table width="300 ">
<tr>
<td><font size="3"><b><font face="Century Gothic" color="#FF0000">Please
enter the Loan Form No.</font></b></font>
<br><br>
<input type="text" name="LoanID">
<input type="submit" name="Submit" value="GO!!">
</td></tr>
</table>
</TD></TR>
</Table>
</form>
***** Questions ********
we can't have 2 "while" function in the codes right..but i hv 2 recordsets...how can i solve this situation?..i need to loop both the recordset...
How?