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

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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old December 14th, 2004, 07:59 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
please help Converting Access SQL statement to work with CF

Hi,

I'm not very famililar with Access but I have to do this for work and I'm kinda stuck on this for a while. I have an SQL statement that worked fine in Access but then when I executed it in CF it didn't work because of the #'s that was surrounding the Dates. I've tried using single quotes around the dates but that didn't seem to solve it.

My SQL statement pulled from Access is

SELECT tblClassExams.StudentID, tblClassExams.Score, tblClassExams.Grade, tblExams.ExamName, tblExams.Date, tblExams.FullScore, tblStudents.LastName, tblStudents.FirstName
FROM ((tblExams INNER JOIN tblClassExams ON tblExams.ExamID = tblClassExams.ExamID) INNER JOIN tblStudents ON tblClassExams.StudentID = tblStudents.StudentID) INNER JOIN tblRegistrarFiles ON tblStudents.StudentID = tblRegistrarFiles.StudentID
WHERE (((tblClassExams.Grade)<70) AND ((tblExams.Date) Between #10/1/04# AND #11/1/04#))
ORDER BY tblStudents.LastName, tblStudents.FirstName, tblExams.Date;


and the error CF returned is
Error Diagnostic Information

Just in time compilation error

Invalid parser construct found on line 15 at position 65. ColdFusion was looking at the following text:10Invalid expression format. The usual cause is an error in the expression structure.

The last successfully parsed CFML construct was a CFQUERY tag occupying document position (12:1) to (12:60).

The specific sequence of files included or processed is:
D:\web\aihsmis\dsp_mandatoryTutoring.cfm

if I change the #s to 's then the error is
ODBC Error Code = 22005 (Error in assignment)

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.



Any suggestions is appreciated. Thanks.

Reply With Quote
  #2  
Old December 14th, 2004, 08:21 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
Try removing pound signs (and not adding single quotes) or using the createODBCDate() function on the dates, and also remove the semicolon at the end.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #3  
Old December 14th, 2004, 08:37 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
Hi,

Thanks for replying. When I removed the # around the dates and the ; and I do
<cfdump var="#studentsNeedingTutoring#">
it seems to return an empty query ( just the column headings) Then I tried to add the createODBCDate function in:

WHERE (((tblClassExams.Grade)<70) AND ((tblExams.Date) Between createODBCDate(10/1/04) AND createODBCDate(11/1/04)))

I think that's the right format, is it? and the error that gets returned is

ODBC Error Code = 37000 (Syntax error or access violation)

[Microsoft][ODBC Microsoft Access Driver] Undefined function 'createODBCDate' in expression.

SQL = "SELECT tblClassExams.StudentID, tblClassExams.Score, tblClassExams.Grade, tblExams.ExamName, tblExams.Date, tblExams.FullScore, tblStudents.LastName, tblStudents.FirstName FROM ((tblExams INNER JOIN tblClassExams ON tblExams.ExamID = tblClassExams.ExamID) INNER JOIN tblStudents ON tblClassExams.StudentID = tblStudents.StudentID) INNER JOIN tblRegistrarFiles ON tblStudents.StudentID = tblRegistrarFiles.StudentID WHERE (((tblClassExams.Grade)<70) AND ((tblExams.Date) Between createODBCDate(10/1/04) AND createODBCDate(11/1/04))) ORDER BY tblStudents.LastName, tblStudents.FirstName, tblExams.Date"

Data Source = "AIHS_NEW"

The error occurred while processing an element with a general identifier of (CFQUERY), occupying document position (12:1) to (12:60) in the template file D:\web\aihsmis\dsp_mandatoryTutoring.cfm.

Reply With Quote
  #4  
Old December 14th, 2004, 09:39 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
If the query is returning an empty recordset and just the headings, then it sounds like the query is running correctly and just not returning any results. Can you guarantee that the query should be returning results given the input?

That said, your use of the function DOES need pound signs around it...

#createODBCDate( '10/1/2004' )#

Reply With Quote
  #5  
Old December 14th, 2004, 11:29 PM
jdang jdang is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: OC, CA
Posts: 49 jdang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 15 m
Reputation Power: 4
Hi Kiteless,

amazingly after I put #createODBCDate('10/1/04')# it works .... thanks so much

JD

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > please help Converting Access SQL statement to work with CF


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 5 hosted by Hostway