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 Professional
Password Reminder
Register
| FAQ | Members List | 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 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
 
 
Thread Tools Search this Thread Display Modes
  #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

Hi,
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


CREATE PROCEDURE ValidateUser
  @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
AS
  SET NOCOUNT ON
  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
    RETURN

  -- 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
    BEGIN
      SET @Valid = 2
      RETURN
    END

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


RETURN
GO


 


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
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



All times are GMT -4. The time now is 06:43 AM.


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