I have written some code to change a labels text property to a value from a database. However I am having problems. The code is as follows:
OleDbConnection Con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\\attDB.accdb");
try
{
    Con.Open();
    string strcom1 = "SELECT t_Name FROM teacher WHERE t_ID="+tID.Text+" && t_pass="+tPass.Text;
    OleDbCommand cmd = new OleDbCommand(strcom1,Con);
    OleDbDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleResult);
    if (reader.HasRows)
    {
        if (reader.Read())
        {
            t_Name.Visible = true;
            t_Name.Text = reader["t_Name"].ToString();
        }
    }
    else
    {
        t_Name.Text = "";   
    }
    reader.Close();
    Con.Close();
}
catch (Exception ex)
{
    MessageBox.Show("Error : " + ex);
}
finally
{
    Con.Close();
}
 
     
     
     
    