Nevron Gauge for SharePoint
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » .NET 5.0 » Block a Password in Database.
       
Author Reply
manoj kumar
posted 60 posts
since Aug 08, 2009 
from

Block a Password in Database.

  Posted on: 09 Feb 2012       
Hi to all. I need your help.

how to block a password in database when a user input continue three times incorrect password in asp .net.
Thanks for Support..
Satish Bhat
posted  169 posts
since  Nov 01, 2004 
from  Mumbai

 Re: Block a Password in Database.
  Posted on: 10 Feb 2012        0  
You can add a Boolean/Bit field to the same database table and set the value to true/1 when user enters wrong password 3 times.

Check that field when user logs in and show him the message if his account is blocked.
Satyapriya Nayak
posted  2264 posts
since  Mar 24, 2010 
from 

 Re: Block a Password in Database.
  Posted on: 10 Feb 2012        0  
Hi Manoj,

Try this...

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Label ID="lb1" runat="server" Font-Bold="True" ForeColor="#FF3300"></asp:Label><br />
     <asp:Label ID="Label1" runat="server" Text="Name" Font-Bold="True"
            Width="100px" BackColor="#FFFF66" ForeColor="#FF3300"></asp:Label>
        <asp:TextBox ID="TextBox_user_name" runat="server" ForeColor="#993300" Width="100px"></asp:TextBox><br />
        <asp:Label ID="Label2" runat="server" Text="Password" Font-Bold="True"
            Width="100px" BackColor="#FFFF66" ForeColor="#FF3300"></asp:Label>
        <asp:TextBox ID="TextBox_password" runat="server" ForeColor="#CC6600"
            TextMode="Password" Width="100px"></asp:TextBox><br />
        <asp:Button ID="btn_login" runat="server" Text="Login" Font-Bold="True"
            BackColor="#CCFF99" onclick="btn_login_Click" /><br />
   
    </div>
    </form>
</body>
</html>



using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
namespace _Default
{
    public partial class _Default : System.Web.UI.Page
    {
        string strConnString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlCommand com;
        string str;
      

        protected void btn_login_Click(object sender, EventArgs e)
        {
            int i = Login(TextBox_user_name.Text, TextBox_password.Text);
            Session["j"] = Convert.ToInt32(Session["j"]) + i;
            int Res = Convert.ToInt32(Session["j"]);
            if (Convert.ToInt32(Session["j"]) < 3)
            {
               
               
            }
               
            else
            {
                Response.Write("<script>alert('User has been locked');</script>");
                Session.Abandon();
              
            }
        }
        private int Login(String uname, String pwd)
        {
            int Counter = 0;
            SqlConnection con = new SqlConnection(strConnString);
            con.Open();
            str = "Select * from login where Username = '" + TextBox_user_name.Text + "' ";
            com = new SqlCommand(str, con);
            SqlDataReader reader = com.ExecuteReader();
            while (reader.Read())
            {
                string UserName = reader[0].ToString();
                string Password = reader[1].ToString();
                 if ((TextBox_user_name.Text == UserName) && (TextBox_password.Text == Password))
                 {
                 Counter = 0;
                 }
                else
                {
                Counter = 1;
                } 
            }
            return Counter;
        }
    }
}


Thanks
       
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved