public void login() { string file_name; file_name = Application.StartupPath + "\\" + "username.txt"; System.IO.StreamWriter objwriter; objwriter = new System.IO.StreamWriter(file_name); objwriter.WriteLine(textBox1.Text); objwriter.Close(); string nam; WeightBridge.Class1 obj = new WeightBridge.Class1(); nam = obj.get(); OleDbConnection con = new OleDbConnection(nam); //OleDbConnection con = new OleDbConnection("D://weightbridge.mdb"); con.Open(); OleDbCommand cmd = new OleDbCommand("SELECT UserName ,pwd FROM User WHERE UserName='" + textBox1.Text + "' AND Password='" + textBox2.Text + "'", con); OleDbDataReader dr = cmd.ExecuteReader(); string userText = textBox1.Text; string passText = textBox2.Text; while (dr.Read()) { if ((dr["UserName"].ToString() == userText) && (dr["Password"].ToString() == passText)) { this.Hide(); MasterPage mp = new MasterPage(); mp.Show(); } else { MessageBox.Show("Invalid username"); } } dr.Close(); con.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)