Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I am currently creating a login form in visual c#, but i am facing problem on how to check if the user input username and password match with the USERNAME and PASSWORD in mysql table. I want the user to input a username and password in the text box then the program will search the table and if the username and password found. the program will display the main form, if not display error message.
 
Please help on how to accomplish this task i am beginner in c# or please help if where can i find a references or resources in c# programming and mysql as database.
 
Thanks.
Posted 13-Oct-12 2:53am
Comments
Wes Aday at 13-Oct-12 9:01am
   
How is this a problem? Get the username and password from the user, connect to your database, and query the database to see if the username and password are valid.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

HI This will help you copy and paste it
 

 
SqlConnection con = new SqlConnection("Connection");
            SqlCommand cmd = new SqlCommand("select pwd,userName from LoginTable",con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(da);
            if (txtPassword.Text == dt.Rows[0]["pwd"].ToString() && txtUserName.Text == dt.Rows[0]["userName"].ToString())
            {
                Response.Redirect("abc.aspx");
            }
            else
            { 
            //Error display Msg
            }
  Permalink  
v2
Comments
Wes Aday at 13-Oct-12 9:11am
   
And this will allow the OP to connect to a MySql database?
Himanshu Yadav at 13-Oct-12 9:12am
   
OP means
Himanshu Yadav at 13-Oct-12 9:13am
   
asking regarding Connection String
Himanshu Yadav at 13-Oct-12 9:18am
   
is this working ?

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

  Print Answers RSS
0 CHill60 360
1 Sarvesh Kumar Gupta 238
2 OriginalGriff 163
3 Sergey Alexandrovich Kryukov 163
4 DamithSL 153


Advertise | Privacy | Mobile
Web02 | 2.8.140709.1 | Last Updated 13 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid