title: How to set the text in a label to a name in database using log-in as key?
body: <p>IDE: Microsoft Visual Studio 2012, DBMS: Microsoft SQL Server 2012</p>
  
  <p>I have 2 ASP.NET webpages, a log-in page and the main page. What I want to do is after I log-in, it would save the ID into the session then use that to retrieve the first name of the user from a database (same table as ID) and into a label on the main page. I was able to do it in the past using:</p>
  
  <pre><code>SqlDataReader
  </code></pre>
  
  <p>But now I have a Data Access Layer class that returns a:</p>
  
  <pre><code>DataTable
  </code></pre>
  
  <p>There's my problem. I can't seem to figure out how to do it. So far, I have these pieces:</p>
  
  <pre><code>Session.Add("StudentID", dt);
  </code></pre>
  
  <p>That was for the log-in page. Here's for the main page:</p>
  
  <pre><code>DataTable dt = (DataTable)Session["StudentUser"];
  int ID = int.Parse(Session["StudentID"].ToString());
  DAL.GetData("SELECT Fname FROM StudentUser WHERE StudentID = " + ID);
  lblName.Text = dt["Fname"].ToString();
  </code></pre>
  
  <p>As for my DAL codes, here they are:</p>
  
  <pre><code>public static DataTable GetData(string sql)
  {
        SqlConnection con = new SqlConnection(DAL.ConnectionString);
        con.Open();
        SqlCommand com = new SqlCommand(sql, con);
        SqlDataAdapter da = new SqlDataAdapter(com);
        DataTable dt = new DataTable();
        da.Fill(dt);
        return dt;
  }
  </code></pre>
  
  <p>My table is called <code>StudentUser</code> and the part I want on the label is <code>Fname</code></p>
  
  <p>When using <code>SqlDataReader</code> (dr) the code for the log-in normally looks like this:</p>
  
  <pre><code>Session.Add("StudentID", dr["StudentID"].ToString());
  </code></pre>
  
  <p>And for the main page:</p>
  
  <pre><code>int ID = int.Parse(Session["StudentID"].ToString());
  SqlCommand com = new SqlCommand("SELECT Fname FROM StudentUser WHERE StudentID = " + ID, con);
  SqlDataReader dr = com.ExecuteReader();
  dr.Read();
  lblName.Text = dr["Fname"].ToString();
  dr.Close();
  </code></pre>
  
  <p>The <code>SqlDataReader</code> code work, but I am determined to use my Data Access Layer whenever possible, even if it leads me to use code that I am unfamiliar with. Please help dear people. :)</p>