Solved

CF doesn't like my SQL table

Posted on 2003-12-10
11
641 Views
Last Modified: 2013-12-24
I get the following error on one of my templates.  History is a table in the Contacts datasource and Contacts is a table in the Contacts datasource.  The area in question is the invalid object name.  My CF datasouces are just fine in the CF admin.
-----------------------------------------

Error Executing Database Query.  
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'History'.  
 
The error occurred in C:\Inetpub\wwwroot\CCL\Contacts\Summary.cfm: line 6
 
4 : <cfset TwoWeeksOld = DateAdd('WW', -2, Now())>
5 :
6 : <cfquery name="PastDue" datasource="Contacts">
7 : SELECT (select max(History.HistoryID) from History where History.RefID = Contacts.ID), Contacts.ID, Contacts.FirstName, Contacts.MiddleName,
8 :             Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments,

 

--------------------------------------------------------------------------------
 
SQL    SELECT (select max(History.HistoryID) from History where History.RefID = Contacts.ID), Contacts.ID, Contacts.FirstName, Contacts.MiddleName, Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments, History.RefID, History.LastContact, History.NextContact FROM Contacts LEFT OUTER JOIN History ON Contacts.ID = History.RefID WHERE HistoryID = (select max(History.HistoryID) from History where History.RefID = Contacts.ID) OR History.HistoryID IS NULL GROUP BY History.HistoryID, Contacts.ID, Contacts.FirstName, Contacts.MiddleName, Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments, History.RefID, History.LastContact, History.NextContact HAVING HISTORY.LastContact < DateAdd(Week,-2,GetDate()) ORDER BY Company ASC  
DATASOURCE   Contacts
VENDORERRORCODE   208
SQLSTATE   42S02
 
0
Comment
Question by:Brian Coughter
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 

Author Comment

by:Brian Coughter
ID: 9913695
Also, I had backed up these MS SQL Server databases and then restored them after reinstalling SQL Server and CF.
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9914031
this is your sql

SELECT (select max(History.HistoryID)
from History
where History.RefID = Contacts.ID), Contacts.ID, Contacts.FirstName, Contacts.MiddleName, Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments, History.RefID, History.LastContact, History.NextContact
FROM Contacts LEFT OUTER JOIN History ON Contacts.ID = History.RefID
WHERE HistoryID = (select max(History.HistoryID) from History where History.RefID = Contacts.ID) OR History.HistoryID IS NULL
GROUP BY History.HistoryID, Contacts.ID, Contacts.FirstName, Contacts.MiddleName, Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments, History.RefID, History.LastContact, History.NextContact
HAVING HISTORY.LastContact < DateAdd(Week,-2,GetDate()) ORDER BY Company ASC  


i think it should be

SELECT History.HistoryID,Contacts.ID, Contacts.FirstName, Contacts.MiddleName, Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments, History.RefID, History.LastContact, History.NextContact
FROM Contacts LEFT OUTER JOIN History ON Contacts.ID = History.RefID
WHERE HistoryID = (select max(History.HistoryID) from History where History.RefID = Contacts.ID) OR History.HistoryID IS NULL
GROUP BY History.HistoryID, Contacts.ID, Contacts.FirstName, Contacts.MiddleName, Contacts.LastName, Contacts.Company, Contacts.Email, History.Method, History.ContactedBy, History.Comments, History.RefID, History.LastContact, History.NextContact
HAVING HISTORY.LastContact < DateAdd(Week,-2,GetDate()) ORDER BY Company ASC  
0
 

Author Comment

by:Brian Coughter
ID: 9914048
I get the same error only this time the Invalid Object is Contacts.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:Brian Coughter
ID: 9914057
This exact SQL query worked fine before I reinstalled everything.
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9914104
have you tried breaking down the sql to make sure that each statement is working?
0
 

Author Comment

by:Brian Coughter
ID: 9914131
I ran this whole query in SQL Enterprise Manager and it returned exactly what it was supposed to return.  It works fine there.
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9914187
>>I ran this whole query in SQL Enterprise Manager and it returned exactly what it was supposed to return.  It works fine there.

thats weird if it works it works....

0
 

Author Comment

by:Brian Coughter
ID: 9914267
The other thing I did was try to add this as a stored procedure in SQL but when I comment out the query and add the following line, I get an error:

LINE:
<cfstoredproc datasource="Contacts" procedure="HistorySummary"></cfstoredproc>

ERROR:
Error Executing Database Query.  
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]Could not find stored procedure 'HistorySummary'.  
 
The error occurred in C:\Inetpub\wwwroot\CCL\Contacts\Summary.cfm: line 20
 
18 : </cfquery>
19 : --->
20 : <cfstoredproc datasource="Contacts" procedure="HistorySummary"></cfstoredproc>
21 :
22 : <html>

 

--------------------------------------------------------------------------------
 
SQL   {call HistorySummary}
DATASOURCE   Contacts
VENDORERRORCODE   2812
SQLSTATE   42000
 
0
 
LVL 25

Accepted Solution

by:
James Rodgers earned 500 total points
ID: 9914678
are you sure that the database has been set upt in cfadmin, it seems as though the databse reference in cfadmin is targeting another schema, it finds the database but not the objects
0
 

Author Comment

by:Brian Coughter
ID: 9914970
Okay, I fixed it.  I had to redo the ODBC Socket and remove/recreate the datasource in ColdFusion.  

Thanks Jester!
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9914989
np... glad i could help

thanks for the points
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question