Jeg vil gerne hente data ud af en db (Access). lMemID er et Session object, som indeholder et medlemID.
SQL = \"SELECT COUNT(*) AS lAntal FROM reservationer WHERE (reservationer.resmedlemsnr = \'\" & lMemID & \"\') AND (reservationer.resdato BETWEEN #\" & nMonday & \"# AND #\" & nSunday & \"#);\"
virker heller ikke: SELECT COUNT(*) AS lAntal FROM reservationer WHERE (reservationer.resmedlemsnr = \'\" & lMemID & \"\') AND (reservationer.resdato >= #\" & nMonday & \"# AND reservationer.resdato <= #\" & nSunday & \"#);\"
Jeg kan ikke får antalet ud. Det kan jeg kun når jeg dele stregen op i to, enten hente resmedlemsne eller resdato. Det vil bare ikke virke i en streng.
Med version 7 af TeamShare tager Lector næste skridt og bygger en platform for AI-agenter, der i højere grad kan følge medarbejderen gennem hele arbejdsprocessen.
so you say SQL = \"SELECT COUNT(*) AS lAntal FROM reservationer WHERE (reservationer.resmedlemsnr = \'\" & lMemID & \"\');\" works, and
SQL = \"SELECT COUNT(*) AS lAntal FROM reservationer WHERE (reservationer.resdato BETWEEN #\" & nMonday & \"# AND #\" & nSunday & \"#);\" works also.
Are you sure that there is data in the database that matches
SQL = \"SELECT COUNT(*) AS lAntal FROM reservationer WHERE (reservationer.resmedlemsnr = \'\" & lMemID & \"\') AND (reservationer.resdato BETWEEN #\" & nMonday & \"# AND #\" & nSunday & \"#);\"
?
Try writing SQL to the screen response.write ... or soemthing, then cut and paste this to a query in Access. If it deesnt work here then you dont have data matching the seelect
It was because that Access is American based and they are the only people on the planet that write the date starting with the month/day/year. nMonday = Month(nMonday) & \"-\" & Day(nMonday) & \"-\" & Year(nMonday) nSunday = Month(nSunday) & \"-\" & Day(nSunday) & \"-\" & Year(nSunday)
SQL = \"SELECT COUNT(*) AS Antal FROM [reservationer] WHERE reservationer.resdato >= #\" & nMonday & \"# AND reservationer.resdato <= #\" & nSunday & \"# AND reservationer.resmedlemsnr = \'\" & lMemID & \"\';\"
SQL = \"SELECT COUNT(*) AS lAntal FROM reservationer WHERE (reservationer.resdato BETWEEN #\" & nMonday & \"# AND #\" & nSunday & \"#);\"
worked!
The dates are the same no matter if this is on its own or togther with the resmedlemsnr!!! Your question was a bit misleading wasnt it!
Another thing, date formats should always be in US format MMDDYYYY not just in Access but I would think ALL SQL databases.
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.