ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old August 22nd, 2003, 11:37 AM
sbelongia sbelongia is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 sbelongia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Help: Access -> ASP & displaying LookUp fields

I have an ASP page pulling data into a table on our web which displays employee information. One of the fields in the Access table I pull the information from is a lookup field referencing another table with the options in the database.

How do I write the SQL query so it returns the text value of the field to my ASP page instead of the numeric value of the lookup table?

i.e.

when I call the field in the table holding the values I get the JTID instead of the JobTitle...

JTID JobTitle
1 Public Service Assistant
2 Library Aide
3 Substitute PSA
4 Shelving Assistant
5 Reference Assistant

Reply With Quote
  #2  
Old August 22nd, 2003, 12:19 PM
karsh44's Avatar
karsh44 karsh44 is offline
Just another guy
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Jun 2003
Location: Wisconsin
Posts: 2,915 karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level)karsh44 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 13 h 6 m 22 sec
Reputation Power: 76
Can you post what your current query is? I'm not quite following how you have things set up.

Reply With Quote
  #3  
Old August 22nd, 2003, 12:27 PM
sbelongia sbelongia is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 2 sbelongia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post ASP query.....

<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim empPhoto 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim lngRecordNo 'Holds the record number to be updated

'Read in the record number
lngRecordNo = CLng(Request.QueryString("ID"))

'Create ADO con obj
Set adoCon = Server.CreateObject("ADODB.Connection")

'Set an active DSN-less connection
adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../fpdb/EmployeeDatabase.mdb")

'Create an ADO recordset object for detail pages
Set empPhoto = Server.CreateObject("ADODB.Recordset")

'Initialise SQL query
strSQL = "SELECT tblEmployeeData.*, tblJobTitlesLU.*, tblDeptLU.* FROM tblEmployeeData, tblJobTitlesLU, tblDeptLU WHERE EID=" & lngRecordNo

'Open the recordset with the SQL query
empPhoto.Open strSQL, adoCon
%>

Reply With Quote
  #4  
Old August 22nd, 2003, 04:54 PM
zimm zimm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 30 zimm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
I am having a difficult time following you, so I'll give you an example of what I think you are trying to do.

Suppose you have 3 tables - Employee table, which is a parent table to a table called management_employee and a table called worker_bees.

In the main employee table, I will have the following fields:
EID, last_name, first_name, mid-initial, street address, city, state, zip, phone, e_mail

In the table management_employee table, i have the following fields:
EID, office_no, ext_no, title, shift

And further suppose that there is similar infor in the worker_bees table.

If I were en employee in your company, and you wanted my information from the management_employee table, you'd have to do something like this:
select last_name, first_name, office_no, ext_no
from employee inner join management_employee
on employee.eid = management_employee.eid
where last_name = 'zimm'


I hope that helped. I'm not sure that that's what you were looking for.

Reply With Quote
  #5  
Old August 23rd, 2003, 06:36 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
Zimm,
table.* returns everything in that table.


sbelongia,
if you're trying to return employee's info, with their job titles and department number, you'll need to join all three tables, excuse the old syntax

Code:
'Initialise SQL query 
strSQL = "SELECT tblEmployeeData.*, tblJobTitlesLU.*, tblDeptLU.* 
FROM tblEmployeeData as e, tblJobTitlesLU as t, tblDeptLU as d
WHERE e.idA* = t.id
AND e.id *= d.id
AND e.id='" & lngRecordNo "'"


if you're using mysql, oracle or if it just doesn't work, look up left join syntax on the *= syntax i used above. The left join says that lets say we have an employee and if for bad DB design reasons, they don't have a listing in Departments because maybe they're a new department or whatever reason, that row would be left out of the return. This left join syntax returns ALL employees no matter what. Let me know if you need more help.

Also, you need ' and a ' around constants in Tsql

Last edited by unatratnag : August 23rd, 2003 at 06:49 AM.

Reply With Quote
  #6  
Old August 24th, 2003, 02:43 PM
zimm zimm is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 30 zimm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
un, I know. I didn't know how much SQL syntax the originator of the thread knew, so I was as explicit as I could be.

Reply With Quote
  #7  
Old August 24th, 2003, 02:50 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
ah sou, wakattayo.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Help: Access -> ASP & displaying LookUp fields


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway