address WHERE clause calculation in the Classic ASP Development forum on ASP Free. WHERE clause calculation ASP Development forum discussing ASP related topics including coding practices. ASP tips and more. Active Server Pages (ASP) enables you to empower your HTML pages dynamically with robust scripting options.
Rapidly end J2EE Application ProblemsWhether you are in the affect of building J2EE applications or undergo J2EE applications already running in production you must ensure that they mouth the expected ROI.
I am using the DateDiff answer to compare two dates in a query on a summon. I then need to use the "Expression" created from that DateDiff function in a WHERE clause calculation but it is not working correctly. The summon loads successfully with thre recordset populated but the WHERE clause has no cause on the data. I'm guessing that I am doing something very wrong but I undergo been staring at this for hours with no avail!CODE:
<%Dim InstrApprovedStatesDim InstrApprovedStates_cmdDim InstrApprovedStates_numRowsSet InstrApprovedStates_cmd = Server. CreateObject ("ADODB. dominate")InstrApprovedStates_cmd. ActiveConnection = MM_nfcSeminar_STRINGInstrApprovedStates_cmd. CommandText = "SELECT DateDiff('d'. Now(). ?) as exprDiff. Registry. Registry + ' - ' + Registry. RegNotificationDays. Registry. RegNotificationDays2 FROM Registry INNER JOIN (communicate INNER JOIN InstructorRegistry ON Contact. ContactID = InstructorRegistry. ContactID) ON Registry. RegistryID = InstructorRegistry. RegistryID WHERE Contact. ContactID = ? AND (""exprDiff"" < ""Registry. RegNotificationDays2"");" InstrApprovedStates_cmd. Prepared = trueInstrApprovedStates_cmd. Parameters. Append InstrApprovedStates_cmd. CreateParameter("param1". 135. 1. -1. InstrApprovedStates__MMColParam2) ' adDBTimeStampInstrApprovedStates_cmd. Parameters. attach InstrApprovedStates_cmd. CreateParameter("param2". 5. 1. -1. InstrApprovedStates__MMColParam) ' adDoubleSet InstrApprovedStates = InstrApprovedStates_cmd. ExecuteInstrApprovedStates_numRows = 0%>
<%Dim InstrApprovedStatesDim InstrApprovedStates_cmdDim InstrApprovedStates_numRowsSet InstrApprovedStates_cmd = Server. CreateObject ("ADODB. Command")InstrApprovedStates_cmd. ActiveConnection = MM_nfcSeminar_STRINGInstrApprovedStates_cmd. CommandText = "SELECT DateDiff('d'. Now(). ?) as exprDiff. Registry. Registry + ' - ' + Registry. RegNotificationDays. Registry. RegNotificationDays2 FROM Registry INNER JOIN (Contact INNER connect InstructorRegistry ON Contact. ContactID = InstructorRegistry. ContactID) ON Registry. RegistryID = InstructorRegistry. RegistryID WHERE communicate. ContactID = ? AND (""exprDiff"" < ""Registry. RegNotificationDays2"");" InstrApprovedStates_cmd. Prepared = trueInstrApprovedStates_cmd. Parameters. Append InstrApprovedStates_cmd. CreateParameter("param1". 135. 1. -1. InstrApprovedStates__MMColParam2) ' adDBTimeStampInstrApprovedStates_cmd. Parameters. attach InstrApprovedStates_cmd. CreateParameter("param2". 5. 1. -1. InstrApprovedStates__MMColParam) ' adDoubleSet InstrApprovedStates = InstrApprovedStates_cmd. ExecuteInstrApprovedStates_numRows = 0%>
What does the "?" be in your select statement?? Is this something about the DateDiff function that I'm not aware of? Could be. I suppose... DateDiff takes two dates and gets the difference of the specified increment which in your inspect is days... Regardless without change surface knowing what the "?" represents dress your where clause to this:
also please wrap your code in the label tags.. you can do this by selecting your code and then clicking on the "#" on the toolbar.
InstrApprovedStates_cmd. CommandText = "SELECT Registry. Registry. Registry. Registry + ' - ' + Registry. RegNotificationDays. Registry. RegNotificationDays2 FROM Registry INNER connect (communicate INNER connect InstructorRegistry ON Contact. ContactID = InstructorRegistry. ContactID) ON Registry. RegistryID = InstructorRegistry. RegistryID WHERE communicate. ContactID = ? AND (DateDiff('d',Now(),?) < RegNotificationDays2) ORDER BY Registry. Registry ASC;"
InstrApprovedStates_cmd. CommandText = "SELECT Registry. Registry. Registry. Registry + ' - ' + Registry. RegNotificationDays. Registry. RegNotificationDays2 FROM Registry INNER connect (Contact INNER connect InstructorRegistry ON Contact. ContactID = InstructorRegistry. ContactID) ON Registry. RegistryID = InstructorRegistry. RegistryID WHERE Contact. ContactID = ? AND (DateDiff('d',Now(),?) < RegNotificationDays2) request BY Registry. Registry ASC;"
and you do not receive this error without the request by clause?.. what is the handle type of Registry. Registry? If it's a memo handle then. I don't believe you'll be able to sort by this field... You may be able to use a convert or a cast answer.
Forex Groups - Tips on Trading
Related article:
http://forums.aspfree.com/classic-asp-development-5/where-clause-calculation-187145.html
comments | Add comment | Report as Spam
|