PDA

View Full Version : Counter problem using acces db


Mhtml
09-28-2002, 06:29 AM
Ok, I have a counter on my site that works fine but I made it by cutting and pasting from various other scripts with no real code created by me.

So now I tried to make one, completely out of my head. I can get it to count but the problem is it counts from 0 to 2 and then stops.

I've no idea why. Here is the code:

<%
Set OdysseyCountConn = Server.CreateObject("adodb.connection")
OdysseyCountConn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & server.mappath("odysseycount.mdb")
GetCount = "SELECT COUNT(Count) as Ccount FROM Counter"
set rs = OdysseyCountConn.Execute(GetCount)
AddCount = "UPDATE Counter SET Count = "& rs("Ccount") + 1
OdysseyCountConn.Execute(AddCount)
OdysseyCountConn.close
Set OdysseyCountConn = nothing
set rs = nothing
%>

whammy
09-28-2002, 04:48 PM
Try [Count] instead of Count, as that's a reserved word in SQL, I'm surprised it works at all!

Other than that I don't see anything wrong with the code offhand...

anandc
10-06-2002, 07:59 PM
Hi

According to me change ur query to like

select max(count) from counter then
nor=rs(0)
----
---
then update it.

Also the fieldname count and the function count, here the
names are same does Access permits this?
better way change ur filed name.

anand