PDA

View Full Version : Update prob.


Mhtml
03-02-2003, 05:50 AM
Ok, I've been learning python for the last month or so and have run into a problem with my vb code the first day back into web dev.


set conn = server.CreateObject("adodb.connection")
set rs = server.CreateObject("adodb.recordset")
conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("fpdb/m5i01.mdb") & ";"

'If session("Counted") <> "true" Then
sqlGetCount = "SELECT * FROM Counter"
rs.Open sqlGetCount, conn
If not rs.eof Then
CountNormal = rs("Count")
CountUnique = rs("CountU")
Else
CountNormal = 0
CountUnique = 0
End If

CountNormal = CountNormal + 1
response.write(CountNormal)
If request.Cookies("BeenHere") <> "true" Then
CountUnique = CountUnique + 1
Response.Cookies("BeenHere") = "true"
End If
rs.close
sqlCountIt = "UPDATE Counter SET Count = " & CountNormal & ", CountU = " & CountUnique & " WHERE Count = " & CountNormal - 1
response.Write(sqlCountIt)
rs.Open sqlCountIt, conn
session("Counted") = "true"
'End If

Set rs = nothing
conn.close
set conn = nothing


That should get the number increment it and update the table where the number is equal to that number -1 in the column alas it doesn't seem to update.

raf
03-02-2003, 09:03 PM
Mhtml,

what exactly are you trying to do ?
It looks to me that 1 sql statement could do all at that without loading in the whole table, the variables and stuff

also, using the variable you update in the conditions doesn't seem logically to me ...

Mhtml
03-03-2003, 08:30 AM
It is a counter , well a rough one. I was coming here to delete my post because I fixed it but you posted to quick ;).

I have restructured it to, more logical now. :)