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.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Feb 10, 2012, 5:12 AM
Try this...
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="._Default" %>
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("");
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
Satish BhatPosted Feb 10, 2012, 4:12 AM
Check that field when user logs in and show him the message if his account is blocked.