Simple Password Form compare using database.Tq
-
Hello friends need help here.. Before this I have learn to create password validating form.Which is user have to key in password to enter another form. The password is default that have set in the coding.Now I need help how to connect to MY Sql database from C# from and compare the password that already I set in MY Sql database,table name Security and Field name password and the password is "ABCD".I dont know how to use SQL server 2005. Below are the coding for the first form that validate to enter to form2. ////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace cubaan1 { public partial class Form1 : Form { Form2 form1 = new Form2(); public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { textBox1.PasswordChar = '*'; //Masking Char textBox1.MaxLength = 14;//Max Length is 14 } private void button1_Click(object sender, EventArgs e) { string strDefaultPassword = "security"; //Keep the default password string strEnteredPassword = textBox1.Text; if (strEnteredPassword == strDefaultPassword) { this.Hide(); form1.ShowDialog(); } else { MessageBox.Show("Wrong password entered"); this.Close(); } } } } ////////////////////////////////////////////////////////// How to change this to connect to MY Sql Database and compare the password from the database. Tq in advance......