Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Selecting data from more than one table


Message #1 by "NAJ" <noni_j@h...> on Mon, 30 Sep 2002 15:28:14
I am having a little bit of trouble.  I have 2 pages a LoginForm.asp and  
LoginResponse.asp.  Whenever I login in the response page retrieves the 
data from 2 different tables, but only the first record in those tables 
are being returned.  I enter the employee id no. on LoginForm.asp, then 
LoginResponse.asp gives me what information I have on them that is in the 
database.  But as i stated before it only returns the first record.  I 
know i don't need a loop, but I'm a little frustrated at this point.  
Could someone help.  Below is my code for both LoginForm.asp & 
LoginResponse.asp.

Thanx in advance.  

Newbie in ASP

LoginForm.asp:

FORM ACTION="LoginResponse.asp" METHOD="POST" name=frmDisplay>
<TABLE BORDER=0>
   <TR>
    <TD>EmployeeID:</TD>
    <TD><INPUT TYPE="Text" NAME="EmployeeID" SIZE="40"></TD>
    </TR>
     <TR>
    <TD></TD>
    <TD align=center><INPUT TYPE="Submit" VALUE="Edit Future Curve"><input 
type="reset" value="Reset">&nbsp;&nbsp;</TD>
  </TR>
</TABLE>
</FORM>
</BODY>
</HTML>


LoginResponse.asp:

<%
dim oRSp
Set oRSp=server.createobject("ADODB.Recordset")
sqltext="Select * FROM Employees INNER JOIN FutureCurve"
sqltext=sqltext & " ON Employees.EmployeeID=FutureCurve.EmployeeID"
oRSp.open sqltext, "dsn=noni"
%>
<FORM ACTION="Update.asp" METHOD="POST" name=frmAdd>
<input type=hidden name=Action value=Add>
	<table>
		<tr>
		<td height = "22" colspan=2></td>
		</tr>
		<tr> 
		<td> Employee ID No.</td>
        <td><font color=navy><%=Request.Form("EmployeeID")%></font></td>
		<td width =150></td>
		<td>Future curve</td>
		<td><font color=navy><%=oRSp("FutureCurve")%></font></td>
		</tr>
		<tr>
		<td> First Name</td>
		<td height ="22"><input type=text name=txtFirstName 
size=30 Value=<%=oRSp("FirstName")%>></td>
		<td width =150></td>
		<td>Last Name</td>
		<td height ="22"><input type=text name=txtLastName size=30 
Value=<%=oRSp("LastName")%>></td>
		</tr>
		<tr>
		<td>Code</td>
		<td height ="22"><input type=text name=txtCode size=10 
Value=<%=oRSp("Code")%>></td>
		</tr>
		<tr>
		<td>Job Title</td>
		<td height ="22"><input type=text name=txtJobTitle size=30 
Value=<%=oRSp("JobTitle")%>></td>
		</tr>
		<tr>
		<td>Supervisor</td>
		<td height ="22"><input type=text name=txtSupervisor 
size=20 Value=<%=oRSp("Supervisor")%>></td>
		</tr>
        <table>
		<tr>
		<td>GOAL:  The goal of the "Future Curve" is to enhance 
our Individual Development Plan (IDP) preparation and implementation
		with a tool to facilitate continued supervisor and 
employee interaction regarding "Employee Development".</td>
        </tr>
        <tr>
        <td><br>DIRECTIONS:  Complete the information below, keeping in 
mind that your training and educational objectives may be met through 
developmental
		assignments, formal training and/or a combination of 
both.  Print, sign and date this form and discuss the contents with your 
		immediate or acting supervisor during your performance 
review, but not later than 30 June.  Your Future Curve should answer the 
		following questions:</td>
        </tr>
        <tr>
        <td>5.  What skills and personal attributes do you currently enjoy 
employing in your daily tasks?<p>
        <textarea rows=6 name=txtQuestion1 cols=40><%=oRSp("Question1")%
></textarea></td><br>
        </tr>
        <tr>
        <td>6.  What types of work assignments do you find the most 
challenging and rewarding?<p>
        <textarea rows=6 name=txtQuestion2 cols=40><%=oRSp("Question2")%
></textarea></td><br>
        </tr>
        <tr>
        <td>7.  Other than the typical federal promotional career path, 
what short-term (1-5 years) professional goals do you have?
		Long term (5 to 10) professional goals.<p>
        <textarea rows=6 name=txtQuestion3 cols=40><%=oRSp("Question3")%
></textarea></td><br>
        </tr>
        <td>8.  Which, if any, of the four requirements portfolios can you 
most closely identify with at this stage of your career?
		How do the career goals you defined above relate to the 
requirements portfolio(s)?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb
sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp; <p>
        <textarea rows=6 name=txtQuestion4 cols=40><%=oRSp("Question4")%
></textarea></td><br>
        </tr>
        <td>9.  What skills do you need to further develop to achieve 
these goals?  What course(s) of study or training program(s)
		will help you develop your skills and move you towards 
reaching the goals you have established?  (This is your input to the
		Individual Development Plan)<p>
        <textarea rows=6 name=txtQuestion5 cols=40><%=oRSp("Question5")%
></textarea></td><br>
        </tr>
         <td>10.  How would the development of the skills you have 
identified above benefit the command?  The taxpayer?  The warfighter?<p>
        <textarea rows=6 name=txtQuestion6 cols=40><%=oRSp("Question6")%
></textarea></td><br>
        </tr>
        </table>
       <br><br><br>
	<tr>
	<td height=60><input type=button name=btnSubmit value=SUBMIT></td>
	</tr>
	</table>
</form>	

<SCRIPT LANGUAGE=vbscript>
Sub btnSubmit_OnClick()

'If we make it this far then submit the form
Call frmAdd.submit()
End Sub
        </SCRIPT>
</p>
</body>
</html>
Message #2 by "Larry Woods" <larry@l...> on Mon, 30 Sep 2002 07:35:27 -0700
Hmmmmmm.

Where did you request; e.g., request("EmployeeID") the Employee
ID from the form?  This has to be "plugged into" the Select
statement for the Select statement to know WHICH Employee ID,
right?  For example:

  sqltext="Select * FROM Employees INNER JOIN FutureCurve"
  sqltext=sqltext & " ON
  Employees.EmployeeID=FutureCurve.EmployeeID WHERE
Employees.EmployeeID = '" & _
  request("EmployeeID") & "'"

You probably need the SINGLE quotation marks around the value of
EmployeeID because I am guessing that the field is defined as
'text'.  If not, then take the single quotes out of the SQL
statement.

Sorry if I missed something...

Larry Woods MCSD, MCT
l.woods, inc.

> -----Original Message-----
> From: NAJ [mailto:noni_j@h...]
> Sent: Monday, September 30, 2002 3:28 PM
> To: Access ASP
> Subject: [access_asp] Selecting data from more than one table
>
>
> I am having a little bit of trouble.  I have 2 pages a
> LoginForm.asp and
> LoginResponse.asp.  Whenever I login in the response
> page retrieves the
> data from 2 different tables, but only the first
> record in those tables
> are being returned.  I enter the employee id no. on
> LoginForm.asp, then
> LoginResponse.asp gives me what information I have on
> them that is in the
> database.  But as i stated before it only returns the
> first record.  I
> know i don't need a loop, but I'm a little frustrated
> at this point.
> Could someone help.  Below is my code for both LoginForm.asp &
> LoginResponse.asp.
>
> Thanx in advance.
>
> Newbie in ASP
>
> LoginForm.asp:
>
> FORM ACTION="LoginResponse.asp" METHOD="POST" name=frmDisplay>
> <TABLE BORDER=0>
>    <TR>
>     <TD>EmployeeID:</TD>
>     <TD><INPUT TYPE="Text" NAME="EmployeeID" SIZE="40"></TD>
>     </TR>
>      <TR>
>     <TD></TD>
>     <TD align=center><INPUT TYPE="Submit" VALUE="Edit
> Future Curve"><input
> type="reset" value="Reset">&nbsp;&nbsp;</TD>
>   </TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>
>
>
> LoginResponse.asp:
>
> <%
> dim oRSp
> Set oRSp=server.createobject("ADODB.Recordset")
> sqltext="Select * FROM Employees INNER JOIN FutureCurve"
> sqltext=sqltext & " ON
> Employees.EmployeeID=FutureCurve.EmployeeID"
> oRSp.open sqltext, "dsn=noni"
> %>
> <FORM ACTION="Update.asp" METHOD="POST" name=frmAdd>
> <input type=hidden name=Action value=Add>
> 	<table>
> 		<tr>
> 		<td height = "22" colspan=2></td>
> 		</tr>
> 		<tr>
> 		<td> Employee ID No.</td>
>         <td><font
> color=navy><%=Request.Form("EmployeeID")%></font></td>
> 		<td width =150></td>
> 		<td>Future curve</td>
> 		<td><font
> color=navy><%=oRSp("FutureCurve")%></font></td>
> 		</tr>
> 		<tr>
> 		<td> First Name</td>
> 		<td height ="22"><input type=text
> name=txtFirstName
> size=30 Value=<%=oRSp("FirstName")%>></td>
> 		<td width =150></td>
> 		<td>Last Name</td>
> 		<td height ="22"><input type=text
> name=txtLastName size=30
> Value=<%=oRSp("LastName")%>></td>
> 		</tr>
> 		<tr>
> 		<td>Code</td>
> 		<td height ="22"><input type=text
> name=txtCode size=10
> Value=<%=oRSp("Code")%>></td>
> 		</tr>
> 		<tr>
> 		<td>Job Title</td>
> 		<td height ="22"><input type=text
> name=txtJobTitle size=30
> Value=<%=oRSp("JobTitle")%>></td>
> 		</tr>
> 		<tr>
> 		<td>Supervisor</td>
> 		<td height ="22"><input type=text
> name=txtSupervisor
> size=20 Value=<%=oRSp("Supervisor")%>></td>
> 		</tr>
>         <table>
> 		<tr>
> 		<td>GOAL:  The goal of the "Future
> Curve" is to enhance
> our Individual Development Plan (IDP) preparation and
> implementation
> 		with a tool to facilitate continued
> supervisor and
> employee interaction regarding "Employee Development".</td>
>         </tr>
>         <tr>
>         <td><br>DIRECTIONS:  Complete the information
> below, keeping in
> mind that your training and educational objectives may
> be met through
> developmental
> 		assignments, formal training and/or a
> combination of
> both.  Print, sign and date this form and discuss the
> contents with your
> 		immediate or acting supervisor during
> your performance
> review, but not later than 30 June.  Your Future Curve
> should answer the
> 		following questions:</td>
>         </tr>
>         <tr>
>         <td>5.  What skills and personal attributes do
> you currently enjoy
> employing in your daily tasks?<p>
>         <textarea rows=6 name=txtQuestion1
> cols=40><%=oRSp("Question1")%
> ></textarea></td><br>
>         </tr>
>         <tr>
>         <td>6.  What types of work assignments do you
> find the most
> challenging and rewarding?<p>
>         <textarea rows=6 name=txtQuestion2
> cols=40><%=oRSp("Question2")%
> ></textarea></td><br>
>         </tr>
>         <tr>
>         <td>7.  Other than the typical federal
> promotional career path,
> what short-term (1-5 years) professional goals do you have?
> 		Long term (5 to 10) professional goals.<p>
>         <textarea rows=6 name=txtQuestion3
> cols=40><%=oRSp("Question3")%
> ></textarea></td><br>
>         </tr>
>         <td>8.  Which, if any, of the four
> requirements portfolios can you
> most closely identify with at this stage of your career?
> 		How do the career goals you defined
> above relate to the
> requirements portfolio(s)?
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
> nbsp;&nbsp;&nbsp;&nb
> sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
> p;&nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp;&nbsp; <p>
>         <textarea rows=6 name=txtQuestion4
> cols=40><%=oRSp("Question4")%
> ></textarea></td><br>
>         </tr>
>         <td>9.  What skills do you need to further
> develop to achieve
> these goals?  What course(s) of study or training program(s)
> 		will help you develop your skills and
> move you towards
> reaching the goals you have established?  (This is
> your input to the
> 		Individual Development Plan)<p>
>         <textarea rows=6 name=txtQuestion5
> cols=40><%=oRSp("Question5")%
> ></textarea></td><br>
>         </tr>
>          <td>10.  How would the development of the
> skills you have
> identified above benefit the command?  The taxpayer?
> The warfighter?<p>
>         <textarea rows=6 name=txtQuestion6
> cols=40><%=oRSp("Question6")%
> ></textarea></td><br>
>         </tr>
>         </table>
>        <br><br><br>
> 	<tr>
> 	<td height=60><input type=button name=btnSubmit
> value=SUBMIT></td>
> 	</tr>
> 	</table>
> </form>
>
> <SCRIPT LANGUAGE=vbscript>
> Sub btnSubmit_OnClick()
>
> 'If we make it this far then submit the form
> Call frmAdd.submit()
> End Sub
>         </SCRIPT>
> </p>
> </body>
> </html>

Message #3 by "NAJ" <noni_j@h...> on Mon, 30 Sep 2002 21:35:12
Thank you very much.  Your suggestion helped, I just had to tweek the last 
thing, WHERE Employees.EmployeeID='" & varEmployee_ID & ";'".

Thank you VERY, VERY, VERY much.

NAJ

> Hmmmmmm.

Where did you request; e.g., request("EmployeeID") the Employee
ID from the form?  This has to be "plugged into" the Select
statement for the Select statement to know WHICH Employee ID,
right?  For example:

  sqltext="Select * FROM Employees INNER JOIN FutureCurve"
  sqltext=sqltext & " ON
  Employees.EmployeeID=FutureCurve.EmployeeID WHERE
Employees.EmployeeID = '" & _
  request("EmployeeID") & "'"

You probably need the SINGLE quotation marks around the value of
EmployeeID because I am guessing that the field is defined as
'text'.  If not, then take the single quotes out of the SQL
statement.

Sorry if I missed something...

Larry Woods MCSD, MCT
l.woods, inc.

> -----Original Message-----
> From: NAJ [mailto:noni_j@h...]
> Sent: Monday, September 30, 2002 3:28 PM
> To: Access ASP
> Subject: [access_asp] Selecting data from more than one table
>
>
> I am having a little bit of trouble.  I have 2 pages a
> LoginForm.asp and
> LoginResponse.asp.  Whenever I login in the response
> page retrieves the
> data from 2 different tables, but only the first
> record in those tables
> are being returned.  I enter the employee id no. on
> LoginForm.asp, then
> LoginResponse.asp gives me what information I have on
> them that is in the
> database.  But as i stated before it only returns the
> first record.  I
> know i don't need a loop, but I'm a little frustrated
> at this point.
> Could someone help.  Below is my code for both LoginForm.asp &
> LoginResponse.asp.
>
> Thanx in advance.
>
> Newbie in ASP
>
> LoginForm.asp:
>
> FORM ACTION="LoginResponse.asp" METHOD="POST" name=frmDisplay>
> <TABLE BORDER=0>
>    <TR>
>     <TD>EmployeeID:</TD>
>     <TD><INPUT TYPE="Text" NAME="EmployeeID" SIZE="40"></TD>
>     </TR>
>      <TR>
>     <TD></TD>
>     <TD align=center><INPUT TYPE="Submit" VALUE="Edit
> Future Curve"><input
> type="reset" value="Reset">&nbsp;&nbsp;</TD>
>   </TR>
> </TABLE>
> </FORM>
> </BODY>
> </HTML>
>
>
> LoginResponse.asp:
>
> <%
> dim oRSp
> Set oRSp=server.createobject("ADODB.Recordset")
> sqltext="Select * FROM Employees INNER JOIN FutureCurve"
> sqltext=sqltext & " ON
> Employees.EmployeeID=FutureCurve.EmployeeID"
> oRSp.open sqltext, "dsn=noni"
> %>
> <FORM ACTION="Update.asp" METHOD="POST" name=frmAdd>
> <input type=hidden name=Action value=Add>
> 	<table>
> 		<tr>
> 		<td height = "22" colspan=2></td>
> 		</tr>
> 		<tr>
> 		<td> Employee ID No.</td>
>         <td><font
> color=navy><%=Request.Form("EmployeeID")%></font></td>
> 		<td width =150></td>
> 		<td>Future curve</td>
> 		<td><font
> color=navy><%=oRSp("FutureCurve")%></font></td>
> 		</tr>
> 		<tr>
> 		<td> First Name</td>
> 		<td height ="22"><input type=text
> name=txtFirstName
> size=30 Value=<%=oRSp("FirstName")%>></td>
> 		<td width =150></td>
> 		<td>Last Name</td>
> 		<td height ="22"><input type=text
> name=txtLastName size=30
> Value=<%=oRSp("LastName")%>></td>
> 		</tr>
> 		<tr>
> 		<td>Code</td>
> 		<td height ="22"><input type=text
> name=txtCode size=10
> Value=<%=oRSp("Code")%>></td>
> 		</tr>
> 		<tr>
> 		<td>Job Title</td>
> 		<td height ="22"><input type=text
> name=txtJobTitle size=30
> Value=<%=oRSp("JobTitle")%>></td>
> 		</tr>
> 		<tr>
> 		<td>Supervisor</td>
> 		<td height ="22"><input type=text
> name=txtSupervisor
> size=20 Value=<%=oRSp("Supervisor")%>></td>
> 		</tr>
>         <table>
> 		<tr>
> 		<td>GOAL:  The goal of the "Future
> Curve" is to enhance
> our Individual Development Plan (IDP) preparation and
> implementation
> 		with a tool to facilitate continued
> supervisor and
> employee interaction regarding "Employee Development".</td>
>         </tr>
>         <tr>
>         <td><br>DIRECTIONS:  Complete the information
> below, keeping in
> mind that your training and educational objectives may
> be met through
> developmental
> 		assignments, formal training and/or a
> combination of
> both.  Print, sign and date this form and discuss the
> contents with your
> 		immediate or acting supervisor during
> your performance
> review, but not later than 30 June.  Your Future Curve
> should answer the
> 		following questions:</td>
>         </tr>
>         <tr>
>         <td>5.  What skills and personal attributes do
> you currently enjoy
> employing in your daily tasks?<p>
>         <textarea rows=6 name=txtQuestion1
> cols=40><%=oRSp("Question1")%
> ></textarea></td><br>
>         </tr>
>         <tr>
>         <td>6.  What types of work assignments do you
> find the most
> challenging and rewarding?<p>
>         <textarea rows=6 name=txtQuestion2
> cols=40><%=oRSp("Question2")%
> ></textarea></td><br>
>         </tr>
>         <tr>
>         <td>7.  Other than the typical federal
> promotional career path,
> what short-term (1-5 years) professional goals do you have?
> 		Long term (5 to 10) professional goals.<p>
>         <textarea rows=6 name=txtQuestion3
> cols=40><%=oRSp("Question3")%
> ></textarea></td><br>
>         </tr>
>         <td>8.  Which, if any, of the four
> requirements portfolios can you
> most closely identify with at this stage of your career?
> 		How do the career goals you defined
> above relate to the
> requirements portfolio(s)?
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&
> nbsp;&nbsp;&nbsp;&nb
> sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs
> p;&nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp;&nbsp; <p>
>         <textarea rows=6 name=txtQuestion4
> cols=40><%=oRSp("Question4")%
> ></textarea></td><br>
>         </tr>
>         <td>9.  What skills do you need to further
> develop to achieve
> these goals?  What course(s) of study or training program(s)
> 		will help you develop your skills and
> move you towards
> reaching the goals you have established?  (This is
> your input to the
> 		Individual Development Plan)<p>
>         <textarea rows=6 name=txtQuestion5
> cols=40><%=oRSp("Question5")%
> ></textarea></td><br>
>         </tr>
>          <td>10.  How would the development of the
> skills you have
> identified above benefit the command?  The taxpayer?
> The warfighter?<p>
>         <textarea rows=6 name=txtQuestion6
> cols=40><%=oRSp("Question6")%
> ></textarea></td><br>
>         </tr>
>         </table>
>        <br><br><br>
> 	<tr>
> 	<td height=60><input type=button name=btnSubmit
> value=SUBMIT></td>
> 	</tr>
> 	</table>
> </form>
>
> <SCRIPT LANGUAGE=vbscript>
> Sub btnSubmit_OnClick()
>
> 'If we make it this far then submit the form
> Call frmAdd.submit()
> End Sub
>         </SCRIPT>
> </p>
> </body>
> </html>


  Return to Index