How to connect My Sql Database to compare string from database.
-
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......
-
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......
In the validation procedure (button1_Click) connect to the mysql database with a special driver (either odbc or a dedicated one from the mysql site) - check http://www.connectionstrings.com/[^] for aditional info. Use ado.net to retrive the password for your user (dataTable, dataTableAdaptor and other stuff like this - check articles for this on codeproject). The database querry should return only one value (the password) for the specified user. And olso, try to use parameters with regex in the querry to aviod insertion attacks. Good luck.
protected internal static readonly ... and I wish the list could continue ...
-
In the validation procedure (button1_Click) connect to the mysql database with a special driver (either odbc or a dedicated one from the mysql site) - check http://www.connectionstrings.com/[^] for aditional info. Use ado.net to retrive the password for your user (dataTable, dataTableAdaptor and other stuff like this - check articles for this on codeproject). The database querry should return only one value (the password) for the specified user. And olso, try to use parameters with regex in the querry to aviod insertion attacks. Good luck.
protected internal static readonly ... and I wish the list could continue ...