Click here to Skip to main content
15,890,995 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,

The users cannot enter the website at the same time. For example, there is a control panel, user name and password. The user enters the name and then password, after that click the button (enter). But, if more than one people can enter this website at the same time then it returns an error.

How can I solve this problem? What should I use?

Regards

Haluk

C#
namespace mekmersite.admin
{
    public class Kullanici
    {

        private bool _kontrol;

        public bool Kontrol
        {
            get { return _kontrol; }
            set { _kontrol = value; }
        }

        private bool _btClick;

        public bool BtClick
        {
            get { return _btClick; }
            set { _btClick = value; }
        }

        public Kullanici()
        {
            this.BtClick = false;
        }

        public void Kontrolet(string kullanici,string sifre)
        {
            string sorgu = "SELECT COUNT(*) FROM LOGIN WHERE USERNAME='" + kullanici + "' AND PASSWORD='" + sifre + "'";
            if (Metotlar.Connection.Komut.IntegerVeriOku(sorgu, 0) > 0)
                this.Kontrol = true;
            else
                this.Kontrol = false;
        }
    }
}


C#
public partial class login : System.Web.UI.Page
{
    //VeriServisi.KullaniciKontrolClient veri = new VeriServisi.KullaniciKontrolClient();
    admin.Kullanici kn = new admin.Kullanici();
    //protected void Page_PreRender(object sender, EventArgs e)
    //{
    //}

    protected void ASPxButton1_Click(object sender, EventArgs e)
    {

        kn.Kontrolet(txt_username.Text, txt_pass.Text);
        if (kn.Kontrol)
        {
            FormsAuthentication.RedirectFromLoginPage(txt_username.Text, true);
            Response.Redirect("~/Default1.aspx");
        }
        else
            Response.Write("Yanlış Giriş Yaptınız");

    }
}
Posted
Updated 14-Jun-12 22:52pm
v3
Comments
[no name] 15-Jun-12 4:34am    
same problem with me but open connection and close whenever no need. instead of one place writing the code.
haluk_78 15-Jun-12 4:37am    
Could you explain more pls? I didn't understand you at all...
[no name] 15-Jun-12 4:41am    
you use APPcode ? if yes, then when you use any sql query just open the connection and at last close the connnection.
haluk_78 15-Jun-12 4:45am    
Pls check it out again...
Rahul Rajat Singh 15-Jun-12 4:47am    
Show me the code that is handling the login related functionality and i will try to find the problem.

1 solution

"sorgu" in your code is string where you are comparing the same with integer.
Are you sure of doing correct parsing while reading the data from database.


Hope this will resolve your problem
Thanks
Amit
 
Share this answer
 
Comments
haluk_78 15-Jun-12 6:06am    
"sorgu" is string but the SELECT statement retuns integer because of "COUNTS(*)" and we got the index of "sorgu"

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900