How to increase this value by 1?

M

Miguel Dias Moura

Hello,

I have a dataset (users) on an ASP.NET/VB page (detail.aspx).

A record on this dataset (users) has 3 fields: "id", "username",
"visits".

The page detail.aspx is called with a variable value in the URL, such
as:
detail.aspx?user=john

I want to increase the value in "visits" field of the record which
"username" is equal to "user".

Example:

id username visits
....
10 helen 120
11 john 400
12 bird 52
....

So when I call the page with "detail.aspx?user=john", the number in
"visits" of record 11 (username=john) will be increase to 401.

Can someone tell me how to do this?

Thanks,
Miguel
 
G

Guest

Hi Miguel,
You can query the dataset for that record using Select and increment the
value.
Dim strUser As String = Request.QueryString("user")
Dim dr As DataRow()
dr = dsusers.Tables(0).Select("Name='" & strUser & "'")
'Since username is unique hopefully u get only one row.
dr(0).Item(2) = dr(0).Item(2) + 1
HTH
srini
 
C

Cirrosi

string userName=Request.QueryString("user");

and then run a query like this

"UPDATE TABLENAME SET VISITS=VISITS+1 WHERE USERNAME='" + userName + "' ";

It's better if you use a prameterized command.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top