private void button1_Click(object sender, EventArgs e)
{
login();
}
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();
nam = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Application.StartupPath + "\\weightbridge.accdb;Persist Security Info=False;";
OleDbConnection con = new OleDbConnection(nam);
con.Open();
OleDbCommand cmd = new OleDbCommand("SELECT UserName,pwd FROM [User] WHERE UserName='" + textBox1.Text + "' AND pwd='" + textBox2.Text + "'", con);
OleDbDataReader dr = cmd.ExecuteReader();
string userText = textBox1.Text;
string passText = textBox2.Text;
while (dr.Read())
{
if ((dr["UserName"].ToString() == userText) && (dr["pwd"].ToString() == passText))
{
this.Hide();
MasterPage mp = new MasterPage();
mp.Show();
this.Hide();
}
else
{
MessageBox.Show("Invalid UserName/Password");
}
}
dr.Close();
con.Close();
}