Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 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 Professional 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
  #1 (permalink)  
Old September 19th, 2007, 06:28 AM
Friend of Wrox
Join Date: May 2005
Location: , , .
Posts: 149
Thanks: 0
Thanked 0 Times in 0 Posts
Default stored procedure problem

i have the following sp.
it checks the user pass and username
whenever a user logss in the logins(integer) field which is set to increment 1 login increments 3 times instead of once
for ex.user has 10 logins when he loggs again logins will become 13
how is that?
the problem is with this line:
 UPDATE Users SET Last_Login = GetDate(), logins = logins + 1 WHERE UserName = @UserName

  @UserName nvarchar(32) = NULL,
  @Password nvarchar(100) = NULL,
  @IPAddress varchar(16) = NULL,
  @Valid int = NULL OUTPUT,
  @userID int = Null OUTPUT,
  @firstname nvarchar(100) = Null OUTPUT
  DECLARE @Check int
  DECLARE @Check2 int

  -- Assume success
  SET @Valid = 1

  -- Validate input parameters
  IF @UserName IS NULL
    SET @Valid = 0
  IF @Password IS NULL
    SET @Valid = 0

  -- Bail on invalid inputs
  IF @Valid = 0

  -- Check UserName and Password
  SELECT @Check = COUNT(*) FROM Users
  WHERE UserName = @UserName AND Password = @Password And UserStatus=1

  SELECT @Check2 = COUNT(*) FROM Blocked WHERE blocked_IP = @IPAddress

  IF @Check2 = 1
      SET @Valid = 2

select @UserID = userid fromUsers WHERE UserName = @Username
 UPDATE Users SET Last_Login = GetDate(), logins = logins + 1 WHERE UserName = @UserName

  -- Assign return value
  SET @Valid = @Check


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with stored procedure analuz ADO.NET 1 July 18th, 2007 08:33 AM
Stored procedure problem akumarp2p Reporting Services 1 May 29th, 2007 01:25 AM
Stored Procedure Problem kwilliams SQL Server 2000 7 June 23rd, 2006 03:03 PM
Stored procedure problem dkspivey SQL Language 2 February 6th, 2006 01:44 PM
Stored Procedure Problem brettdavis4 ASP.NET 1.0 and 1.1 Basics 7 November 3rd, 2003 09:46 PM

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