There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
ASP Access/SQL statement


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
cperrywebrat's Avatar
Member with 80 posts.
 
Join Date: Oct 2004
Experience: Advanced
07-Oct-2004, 04:56 PM #1
SOLVED: ASP Access/SQL statement
I have solved the problem - I printed the SQL3 string and OtherDepartment2 thru OtherDepartment5 had an extra space in front of the field, so I did a Trim(OtherDepartmentX) and retrieved the values
************************************
Original problem below
************************************
I am baffled. I have been spending several hours to figure out why I am not pulling all records from my database. I have an sql statement:

SQL3="SELECT * FROM department_table WHERE (department='" & department & _
"' OR department='" & homeDepartment & _
"' OR department='" & OtherDepartment1 & _
"' OR department='" & OtherDepartment2 & _
"' OR department='" & OtherDepartment3 & _
"' OR department='" & OtherDepartment4 & _
"' OR department='" & OtherDepartment5 & "')"

I have values for all of the above which match. However, only the department, homeDepartment, and OtherDepartment1 gets pulled from the db.
Here is my complete code:

SQL3="SELECT * FROM department_table WHERE (department='" & department & _
"' OR department='" & homeDepartment & _
"' OR department='" & OtherDepartment1 & _
"' OR department='" & OtherDepartment2 & _
"' OR department='" & OtherDepartment3 & _
"' OR department='" & OtherDepartment4 & _
"' OR department='" & OtherDepartment5 & "')"

SET cn=Server.CreateObject("ADODB.Connection")
openStr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../../db/SafetyReports/SafetyReports.mdb")
cn.OPEN openStr
SET records=Server.CreateObject("ADODB.Recordset")

records.OPEN SQL3, cn, 2, 2
IF records.BOF or records.EOF THEN
directors="Not found"
ELSE
DO WHILE NOT records.EOF
Response.Write records("ID") & " - "
Response.Write records("department") & " - "
Response.Write records("dirUsername") & " - "
Response.Write records("admUsername") & "<BR>"
records.MoveNext
LOOP
END IF
records.CLOSE

Last edited by cperrywebrat : 08-Oct-2004 09:42 AM. Reason: Change Title to SOLVED
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:16 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.