Please support our ColdFusion advertiser: Programming Forums
Views: 7103 | Replies: 16
![]() |
•
•
Join Date: Jul 2005
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
I would like to create a page which will pull news items according to today's date. What I have is a database which users input thier news information. But now I need to have the information output to a page which will change daily according to the current date. The BeginDate fields and EndDate fields are in date format in my database. Here's what I have to work with...
<!---Retrieve news from database--->
<cfquery name="NewsQuery" datasource="News">
SELECT *
FROM News
WHERE BeginDate <= '#Dateformat(Now(), "mm/dd/yyyy")#'
AND EndDate >= '#Dateformat(Now(), "mm/dd/yyyy")#'
</cfquery>
<!---Output news to page--->
<cfoutput query="NewsQuery">
<p>
#NewsTitle#
#NewsDesc#
#NewsDate#
</p>
</cfoutput>
Anything specific you can provide me with is greatly appreciated. Please provide me some code... I've been working on trying to get this to work for weeks!
Thanks for your help!!! :eek: :mrgreen:
<!---Retrieve news from database--->
<cfquery name="NewsQuery" datasource="News">
SELECT *
FROM News
WHERE BeginDate <= '#Dateformat(Now(), "mm/dd/yyyy")#'
AND EndDate >= '#Dateformat(Now(), "mm/dd/yyyy")#'
</cfquery>
<!---Output news to page--->
<cfoutput query="NewsQuery">
<p>
#NewsTitle#
#NewsDesc#
#NewsDate#
</p>
</cfoutput>
Anything specific you can provide me with is greatly appreciated. Please provide me some code... I've been working on trying to get this to work for weeks!
Thanks for your help!!! :eek: :mrgreen:
•
•
Join Date: Jul 2005
Posts: 8
Reputation:
Rep Power: 0
Solved Threads: 0
Thank you for your reply!
Well with the code I recieve the following message:
==============================================================
Error Occurred While Processing Request
Error Executing Database Query.
[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Table 'News' is exclusively locked by user 'Admin' on machine 'MY_PC'.
The Error Occurred in C:\CFusionMX\wwwroot\News\test.cfm: line 20
18 : </head>
19 :
20 : <body>
21 : <cfoutput query="NewsQuery">
22 : <p>
--------------------------------------------------------------------------------
SQL SELECT * FROM News WHERE StartDate <= '07/27/2005' AND StopDate >= '07/27/2005'
DATASOURCE News
VENDORERRORCODE -1302
SQLSTATE HY000
Please Try The Following:
Check the CFML Reference Manual to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
Remote Address 127.0.0.1
Referer
Date/Time 27-Jul-05 08:49 AM
Stack Trace (click to expand)
at cftest2ecfm599768075.runPage(C:\CFusionMX\wwwroot\News\test.cfm:20) at cftest2ecfm599768075.runPage(C:\CFusionMX\wwwroot\News\test.cfm:20)
java.sql.SQLException: [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Table 'News' is exclusively locked by user 'Admin' on machine 'MY_PC'.
at com.merant.sequelink.ssp.Diagnostic.toSQLException(Unknown Source)
at com.merant.sequelink.ssp.Chain.cnvDiagnostics(Unknown Source)
at com.merant.sequelink.ssp.Chain.decodeDiagnostic(Unknown Source)
at com.merant.sequelink.ssp.Chain.decodeBody(Unknown Source)
at com.merant.sequelink.ssp.Chain.decode(Unknown Source)
at com.merant.sequelink.ssp.Chain.send(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StatementContext.send(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StmtCtxtState._getDescribeInfo(Unknown Source)
at com.merant.sequelink.ctxt.stmt.CreatedStmtCtxt.getDescribeInfo(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StatementContext.getDescribeInfo(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StmtCtxtState._execDirect(Unknown Source)
at com.merant.sequelink.ctxt.stmt.CreatedStmtCtxt.execDirect(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StatementContext.execDirect(Unknown Source)
at com.merant.sequelink.jdbc.SequeLinkStatement._execute(Unknown Source)
at com.merant.sequelink.jdbc.SequeLinkStatement.execute(Unknown Source)
at jrun.sql.JRunStatement.execute(JRunStatement.java:304)
at coldfusion.sql.Executive.executeQuery(Unknown Source)
at coldfusion.sql.Executive.executeQuery(Unknown Source)
at coldfusion.sql.SqlImpl.execute(Unknown Source)
at coldfusion.tagext.sql.QueryTag.doEndTag(Unknown Source)
at cftest2ecfm599768075.runPage(C:\CFusionMX\wwwroot\News\test.cfm:20)
at coldfusion.runtime.CfJspPage.invoke(Unknown Source)
at coldfusion.tagext.lang.IncludeTag.doStartTag(Unknown Source)
at coldfusion.filter.CfincludeFilter.invoke(Unknown Source)
at coldfusion.filter.ApplicationFilter.invoke(Unknown Source)
at coldfusion.filter.PathFilter.invoke(Unknown Source)
at coldfusion.filter.ExceptionFilter.invoke(Unknown Source)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(Unknown Source)
at coldfusion.filter.BrowserFilter.invoke(Unknown Source)
at coldfusion.filter.GlobalsFilter.invoke(Unknown Source)
at coldfusion.filter.DatasourceFilter.invoke(Unknown Source)
at coldfusion.CfmServlet.service(Unknown Source)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:241)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
=============================================================
I removed the mask. I still get the error. If I remove the WHERE statement then it works. Pulling all the information from the database. All I want is for the query to look at my news database go to the BeginDate and EndDate fields and determine if it is within the time range for the time which it is to be presented. I want it to check and say today is 7/27/2005, is there any news item which needs to be presented today? I hope that helps. If it's not clear please let me know. I really appreciate your help! You dont know how frustrated I am with this.
Well with the code I recieve the following message:
==============================================================
Error Occurred While Processing Request
Error Executing Database Query.
[MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Table 'News' is exclusively locked by user 'Admin' on machine 'MY_PC'.
The Error Occurred in C:\CFusionMX\wwwroot\News\test.cfm: line 20
18 : </head>
19 :
20 : <body>
21 : <cfoutput query="NewsQuery">
22 : <p>
--------------------------------------------------------------------------------
SQL SELECT * FROM News WHERE StartDate <= '07/27/2005' AND StopDate >= '07/27/2005'
DATASOURCE News
VENDORERRORCODE -1302
SQLSTATE HY000
Please Try The Following:
Check the CFML Reference Manual to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)
Remote Address 127.0.0.1
Referer
Date/Time 27-Jul-05 08:49 AM
Stack Trace (click to expand)
at cftest2ecfm599768075.runPage(C:\CFusionMX\wwwroot\News\test.cfm:20) at cftest2ecfm599768075.runPage(C:\CFusionMX\wwwroot\News\test.cfm:20)
java.sql.SQLException: [MERANT][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Table 'News' is exclusively locked by user 'Admin' on machine 'MY_PC'.
at com.merant.sequelink.ssp.Diagnostic.toSQLException(Unknown Source)
at com.merant.sequelink.ssp.Chain.cnvDiagnostics(Unknown Source)
at com.merant.sequelink.ssp.Chain.decodeDiagnostic(Unknown Source)
at com.merant.sequelink.ssp.Chain.decodeBody(Unknown Source)
at com.merant.sequelink.ssp.Chain.decode(Unknown Source)
at com.merant.sequelink.ssp.Chain.send(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StatementContext.send(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StmtCtxtState._getDescribeInfo(Unknown Source)
at com.merant.sequelink.ctxt.stmt.CreatedStmtCtxt.getDescribeInfo(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StatementContext.getDescribeInfo(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StmtCtxtState._execDirect(Unknown Source)
at com.merant.sequelink.ctxt.stmt.CreatedStmtCtxt.execDirect(Unknown Source)
at com.merant.sequelink.ctxt.stmt.StatementContext.execDirect(Unknown Source)
at com.merant.sequelink.jdbc.SequeLinkStatement._execute(Unknown Source)
at com.merant.sequelink.jdbc.SequeLinkStatement.execute(Unknown Source)
at jrun.sql.JRunStatement.execute(JRunStatement.java:304)
at coldfusion.sql.Executive.executeQuery(Unknown Source)
at coldfusion.sql.Executive.executeQuery(Unknown Source)
at coldfusion.sql.SqlImpl.execute(Unknown Source)
at coldfusion.tagext.sql.QueryTag.doEndTag(Unknown Source)
at cftest2ecfm599768075.runPage(C:\CFusionMX\wwwroot\News\test.cfm:20)
at coldfusion.runtime.CfJspPage.invoke(Unknown Source)
at coldfusion.tagext.lang.IncludeTag.doStartTag(Unknown Source)
at coldfusion.filter.CfincludeFilter.invoke(Unknown Source)
at coldfusion.filter.ApplicationFilter.invoke(Unknown Source)
at coldfusion.filter.PathFilter.invoke(Unknown Source)
at coldfusion.filter.ExceptionFilter.invoke(Unknown Source)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(Unknown Source)
at coldfusion.filter.BrowserFilter.invoke(Unknown Source)
at coldfusion.filter.GlobalsFilter.invoke(Unknown Source)
at coldfusion.filter.DatasourceFilter.invoke(Unknown Source)
at coldfusion.CfmServlet.service(Unknown Source)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:241)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:527)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:348)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:451)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:294)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
=============================================================
I removed the mask. I still get the error. If I remove the WHERE statement then it works. Pulling all the information from the database. All I want is for the query to look at my news database go to the BeginDate and EndDate fields and determine if it is within the time range for the time which it is to be presented. I want it to check and say today is 7/27/2005, is there any news item which needs to be presented today? I hope that helps. If it's not clear please let me know. I really appreciate your help! You dont know how frustrated I am with this.
•
•
Join Date: Jun 2005
Posts: 15
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
•
•
Originally Posted by Torch7
I see it appears to be an issue with the data type in the database. What field type is beginDate and EndDate? I did something very similar with another application, and ran into issue with ACCESS dates and ColdFusion DateFormat... attempting to recall what I did or locate the code.
Try USING #CreateODBCDate(Now())# instead of DateFormat.
•
•
Join Date: Jun 2005
Posts: 15
Reputation:
Rep Power: 4
Solved Threads: 1
Okay...
Question... why is the end date significant are you attempting to syndicate.
IF StartDte and EndDte are both #CreateODBCDate(NOW())# Then it seems like the ENDDte is not necessary.
Try just
WHERE BeginDate = #DateFormat(Now())#
OR WHERE BeginDate = #CreateODBCDate(Now())#
Just to see how access responds to the query.
Note that the single quotes are not around the DateField...
I remember having this issue some time ago, and it was something very small, that had to do with access.
Question... why is the end date significant are you attempting to syndicate.
IF StartDte and EndDte are both #CreateODBCDate(NOW())# Then it seems like the ENDDte is not necessary.
Try just
WHERE BeginDate = #DateFormat(Now())#
OR WHERE BeginDate = #CreateODBCDate(Now())#
Just to see how access responds to the query.
Note that the single quotes are not around the DateField...
I remember having this issue some time ago, and it was something very small, that had to do with access.
•
•
Join Date: Jun 2005
Posts: 15
Reputation:
Rep Power: 4
Solved Threads: 1
Okay... that's how I thought you were using it.
SO my thought would be that outlook is having issue with the >= & <=
I have performed queries like this in mysql but can't recall doing it in access. I attempted to test the code out with a mock database in access , and I couldn't get any records to show directly from the access query wizard.
I would say the next thing is to try the code with Begin date and the >= to see if that is infact the issue.
SO my thought would be that outlook is having issue with the >= & <=
I have performed queries like this in mysql but can't recall doing it in access. I attempted to test the code out with a mock database in access , and I couldn't get any records to show directly from the access query wizard.
I would say the next thing is to try the code with Begin date and the >= to see if that is infact the issue.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode