|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can you use datepart in an SQL query within an ASP page. The following code gives the following error when I try and use the record set
Error Type: ADODB.Field (0x800A0BCD) Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. MS SQL: sqlstr = "select userid, count(investigationtype) as numof " &_ "FROM tblitInvestigation WHERE (closedate is null or datepart(ww,closedate) >= " & qrywk & " and datepart(yyyy,closedate) = " & qryyr & ") and (datepart(ww,opendate) < " & qrywk & " and datepart(yyyy,opendate) = " & qryyr & ") AND userid ='" & rsuser("userid") & "' and branch like '" & request.form("lstbranch") & "' group by userid" Many thanks in advance for any advice. Cheers, Jon ![]() |
|
#2
|
|||
|
|||
|
Well, so far it's correct. DatePart can be used this way, of course. But what about your query? Did you manage to execute it elsewhere? It looks very restrictive and maybe it just has no result set.
This piece may fail as well: like '" & request.form("lstbranch") & "' ... may be better this way: like '" & request.form("lstbranch") & "%' ... |
|
#3
|
|||
|
|||
|
Thanks for your help,
I have made a few changes to the query and everything is working fine now. You were right; when I tested the query in SQL Query Analyzer it did not return any results. Cheers, Jon |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Help with datepart in SQL/ASP |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|