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
Solved

Proper formatting/need for cfqueryparam w/CF_SQL_TIMESTAMP & TimeFormat

Posted on 2010-08-14
2
722 Views
Last Modified: 2012-06-27

I am getting the following error:


The error occurred in E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 812
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 798
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 739
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 134
Called from E:\CustomerData\webspaces\webspace_00104265\wwwroot\modules\q_event.cfm: line 1
810 : <cfqueryparam cfsqltype="cf_sql_integer" value="#posted_by#">,
811 : <cfqueryparam cfsqltype="CF_SQL_TIMESTAMP" value="#dateformat(now(), 'mm/dd/yyyy')#">,
812 : <cfqueryparam cfsqltype="CF_SQL_TIMESTAMP" value="#TimeFormat(Now(), 'hh:mm tt')#">)
813 : SELECT @@Identity AS MusicID
814 :



do I even need to be using the cfqueryparam?

The dateformat(now() seems to be working but not the TimeFormat(Now()

0
Comment
Question by:btintermedia
2 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 33439296
Can you post the whole query and the error message? That snippet just shows some sort of error occurred. But not what the error is.

>> do I even need to be using the cfqueryparam?

   Technically, no. But it's a good practice for several reasons: performance, security and
   correct interpretation of date values.

>>  SELECT @@Identity AS MusicID

    For CF8+ it's better to use cfquery's result attribute to get the new ID. For other versions
    SCOPE_IDENTITY() is probably what you want instead.  @@Identity can return the wrong
    value under certain conditions.
    http://msdn.microsoft.com/en-us/library/ms190315.aspx
0
 

Author Closing Comment

by:btintermedia
ID: 33462119
I determined that I was passing a wrong variable, farther back in application - but I had forgotten that I had not upgraded this code to the correct standard in terms of getting the new recordset that is generated, so I am awarding points.

thanks for you help
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

808 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