Hi all, In this i will show how to update user hits to particular site based upon the value which was stored in the database Create Table counter with column hit and insert values into it CREATE TABLE [dbo].[counter] (
[hit] [int] NOT NULL
) ON [PRIMARY]
INSERT [dbo].[counter] (hit) VALUES (1) Create a procedure hitcounter to count the hits CREATE PROCEDURE dbo.hitcounter
AS
BEGIN
SET NOCOUNT ON
DECLARE @hits INT
update counter set hit = hit + 1
SELECT hit from counter
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO This is ASP page <%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<script language="VB" runat="server">
Sub Page_Load(Source as Object, E as EventArgs)
Dim objCon As New SQLConnection("server=ServerName;User id=Database UserName;password=Password;database=Database Name")
Dim cmd As SQLCommand = New SQLCommand("EXEC dbo.hitcounter", objCon)
objCon.Open()
Dim r as SQLDataReader
r = cmd.ExecuteReader()
r.read()
strCounter.text = "Hit : " & r.item(0)
end sub
</script>
<html>
<head>
</head>
<body>
<asp:label ID="strCounter" runat="server"/>
</body>
</html>
Cheers!!!