private void cmdlogsec_Click(object sender, EventArgs e)
{
try
{
string myConnection = "datasource=localhost; database=secretary; port=3306; username=root; password=palo";
MySqlConnection myConn = new MySqlConnection(myConnection);
myConn.Open();
string userText = txtusersec.Text;
string passText = txtpasssec.Text;
MySqlCommand selectcomand = new MySqlCommand("select username,password from secretary.tblseclog where username=' " + this.txtusersec.Text + "' and password ='" + this.txtpasssec.Text + "' ", myConn);
MySqlDataAdapter myDataAdapter = new MySqlDataAdapter(selectcomand);
DataTable dt = new DataTable();
myDataAdapter.Fill(dt);
if (dt.Rows.Count > 0)
{
MessageBox.Show("Login Sucess!!");
selectcomand = new MySqlCommand("select username,password from secretary.tblseclog where username=' " + this.txtusersec.Text + "' and password ='" + this.txtpasssec.Text + "' ", myConn);
selectcomand.Parameters.AddWithValue("@username", userText);
selectcomand.Parameters.AddWithValue("@password", passText);
MySqlDataReader myreader;
myreader = selectcomand.ExecuteReader();
Form5 myForm5 = new Form5();
myForm5.Show();
this.Hide();
}
else
{
MessageBox.Show("Access Denied!!");
myConn.Close();
}
}
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.