Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 12th, 2009, 04:14 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
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
 
Old February 12th, 2009, 08:14 PM
Friend of Wrox
 
Join Date: Nov 2007
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..
 
Old February 13th, 2009, 05:34 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

thank you that did it
__________________
bx





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





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