Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 12th, 2009, 04:14 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default How to count the button clicks

Hi there i am trying to count the clicks in a button which i have done but i need to update a table so next time the user log in the label count will display the hits.
this is what i have
Code:
sent.Text = Val(sent.Text) + 1
Dim con AsNew SqlConnection(ConfigurationManager.ConnectionStrings("test").ConnectionString)
Dim cmdd AsNew SqlCommand("UPDATE Users SET NumberEmailSent = '" & Me.sent.Text & " ' Where Name= @Name")
cmdd.Parameters.Add("@Name", Data.SqlDbType.NVarChar, 50).Value = Me.lblUser.Text
cmdd.Connection = con
con.Open()
cmdd.ExecuteNonQuery()
con.Close()
what this does it updates the lable +1 and the table at the same time but if i log out and log in the label is reset to 0 and if i click the button the table will alsow be reset to 1.
i need to be able to add them up
thanks
__________________
bx
Reply With Quote
  #2 (permalink)  
Old February 12th, 2009, 08:14 PM
Friend of Wrox
 
Join Date: Nov 2007
Location: Central Florida, USA.
Posts: 207
Thanks: 2
Thanked 15 Times in 15 Posts
Default Well...

What's the code you are using to set the label value? you can't just expect the label to set it's own value? i assume you are doing something similar to

Code:
Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("test").ConnectionString)
Dim cmdd As New SqlCommand("select NumberEmailSent from Users Where Name= @Name")
Dim dr as SqlDataReader = Nothing
cmdd.Parameters.Add("@Name", Data.SqlDbType.NVarChar, 50).Value = Me.lblUser.Text
cmdd.Connection = con
con.Open()
dr = cmdd.ExecuteReader()

DR.Read()
If DR.HasRows() = True Then
Me.lblClicks.Text = DR("NumberEmailSent").ToString
End If

con.Close()
__________________
Jason Hall

Follow me on Twitter @jhall2013

Last edited by alliancejhall; February 12th, 2009 at 08:18 PM..
Reply With Quote
  #3 (permalink)  
Old February 13th, 2009, 05:34 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

thank you that did it
__________________
bx
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
httpmodule to count number of clicks a specific li Sheraz Khan ASP.NET 2.0 Professional 0 November 15th, 2008 02:35 PM
Refresh Page when User Clicks on Back Button testsubject Visual Studio 2005 1 June 26th, 2006 03:46 AM
Chapter 14 Responding to clicks tfackler BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 2 February 1st, 2005 11:40 AM
capturing clicks on sql report tabs ilfirinelda BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 October 10th, 2004 10:52 PM
Recording clicks on intrapage links tomofdarwin VBScript 3 May 22nd, 2004 11:07 AM



All times are GMT -4. The time now is 08:12 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.