Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Count with database


Message #1 by "SD-Studios" <info@s...> on Fri, 21 Sep 2001 19:19:39 +0200
Hi!

I've got this problem with a page that is suppose to count downloads. I use

this code:



<%

Function RetrieveAndIncrementCount()



Const adOpenKeyset = 1

Const adLockPessimistic = 2

Const adCmdText = &H0001



Set rsCounter = Server.CreateObject("ADODB.Recordset")

Set objCon = Server.CreateObject("ADODB.Connection")



objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &

Server.MapPath("database.mdb")

SQL = "SELECT downloads FROM games WHERE gametitle='" &

Request.QueryString("game") & "';"



rsCounter.Open SQL, objCon, adOpenKeyset, adLockPessimistic, adCmdText



iCount = rsCounter("downloads")



rsCounter.Fields("downloads") = iCount + 1

rsCounter.Update



rsCounter.Close

objCon.Close



End Function

%>



Togehter with this I as u can see use an Access-database. The field

downloads is set as Integer. But this doesn't count! Can someone please help

me? =)

--

Martin Johansson



Message #2 by "SD-Studios" <info@s...> on Sun, 23 Sep 2001 20:54:29 +0200
Hi!

Got no answer, I've still got this problem with a page that is suppose to

count downloads. I use

this code:



<%

Function RetrieveAndIncrementCount()



Const adOpenKeyset = 1

Const adLockPessimistic = 2

Const adCmdText = &H0001



Set rsCounter = Server.CreateObject("ADODB.Recordset")

Set objCon = Server.CreateObject("ADODB.Connection")



objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &

Server.MapPath("database.mdb")

SQL = "SELECT downloads FROM games WHERE gametitle='" &

Request.QueryString("game") & "';"



rsCounter.Open SQL, objCon, adOpenKeyset, adLockPessimistic, adCmdText



iCount = rsCounter("downloads")



rsCounter.Fields("downloads") = iCount + 1

rsCounter.Update



rsCounter.Close

objCon.Close



End Function

%>



Togehter with this I as u can see use an Access-database. The field

downloads is set as Integer. But this doesn't count! Can someone please help

me? =)

--

Martin Johansson





Message #3 by David Cameron <dcameron@i...> on Mon, 24 Sep 2001 09:34:45 +1000
I'm not sure if you get anything out of a Request object inside a function,

so that may be your problem. It is a bad practice to use that inside a fn

anyway. You should be passing that into the fn.



Also I suggest what I always suggest when a query is not returning the

expected results.



1. Use response.write to do a screen dump of the SQL string.

2. Check that this is what you meant to generate.

3. Test it in you Access db.



regards

David Cameron

nOw.b2b

dcameron@i...



-----Original Message-----

From: SD-Studios [mailto:info@s...]

Sent: Monday, 24 September 2001 7:42 AM

To: ASP Databases

Subject: [asp_databases] Count with database...





Hi!

Got no answer, I've still got this problem with a page that is suppose to

count downloads. I use

this code:



<%

Function RetrieveAndIncrementCount()



Const adOpenKeyset = 1

Const adLockPessimistic = 2

Const adCmdText = &H0001



Set rsCounter = Server.CreateObject("ADODB.Recordset")

Set objCon = Server.CreateObject("ADODB.Connection")



objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &

Server.MapPath("database.mdb")

SQL = "SELECT downloads FROM games WHERE gametitle='" &

Request.QueryString("game") & "';"



rsCounter.Open SQL, objCon, adOpenKeyset, adLockPessimistic, adCmdText



iCount = rsCounter("downloads")



rsCounter.Fields("downloads") = iCount + 1

rsCounter.Update



rsCounter.Close

objCon.Close



End Function

%>



Togehter with this I as u can see use an Access-database. The field

downloads is set as Integer. But this doesn't count! Can someone please help

me? =)

--

Martin Johansson
Message #4 by "Ken Schaefer" <ken@a...> on Mon, 24 Sep 2001 15:56:17 +1000
Why doesn't it work? Does it generate an error? Does it update the field?

Are you sure there are any records returned by your search? etc etc. Please

explain what the problem is.



Cheers

Ken



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

----- Original Message -----

From: "SD-Studios" <info@s...>

To: "ASP Databases" <asp_databases@p...>

Sent: Monday, September 24, 2001 7:42 AM

Subject: [asp_databases] Count with database...





: Hi!

: Got no answer, I've still got this problem with a page that is suppose to

: count downloads. I use

: this code:

:

: <%

: Function RetrieveAndIncrementCount()

:

: Const adOpenKeyset = 1

: Const adLockPessimistic = 2

: Const adCmdText = &H0001

:

: Set rsCounter = Server.CreateObject("ADODB.Recordset")

: Set objCon = Server.CreateObject("ADODB.Connection")

:

: objCon.Open "Driver={Microsoft Access Driver (*.mdb)};dbq=" &

: Server.MapPath("database.mdb")

: SQL = "SELECT downloads FROM games WHERE gametitle='" &

: Request.QueryString("game") & "';"

:

: rsCounter.Open SQL, objCon, adOpenKeyset, adLockPessimistic, adCmdText

:

: iCount = rsCounter("downloads")

:

: rsCounter.Fields("downloads") = iCount + 1

: rsCounter.Update

:

: rsCounter.Close

: objCon.Close

:

: End Function

: %>

:

: Togehter with this I as u can see use an Access-database. The field

: downloads is set as Integer. But this doesn't count! Can someone please

help

: me? =)

: --

: Martin Johansson

:

:

:

:




$subst('Email.Unsub')




  Return to Index