Question

I have a solution in Visual studio2012 with one website and one winform app.In the website I use the asp.net configuration for login and register.The authentication in the website is working perfect.It uses usernames and stores passwords(Hashes).I need to login in the winform app with the users of the website.I try this but it is not workingseems.

SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Basketball;Integrated Security=True;User ID=userpol;Password=poluser");
SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From aspnet_Membership where UserId='" + textBoxUser.Text + "' and Password ='" + textBoxPass.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
    this.Hide();
    GameChoose gc = new GameChoose();
    gc.Show();
}
else
{
    MessageBox.Show("please check your username and password");
}

Any Idea how to How to Use a Membership Provider of ASP.NET in WINFORM Application ?I want only authentication user,pass.

Was it helpful?

Solution

Finally I made it using a Web Service

   public bool Validate(string username, string password)
    {
        return Membership.ValidateUser(username, password);
    }

and in login form:

   bool result = basketballWcf.Validate(textBoxUser.Text, textBoxPass.Text);
        if (result)
        {
            this.Hide();
            GameChoose gc = new GameChoose();
            gc.Show();
        }
        else
        {
            MessageBox.Show("check please USERNAME or PASSWORD");
            textBoxPass.Text = "";
        }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top