title: How do I use the datatable to retrieve data in my table from SQL Server in c #
body: <p>i want to retrieve data from my database to my window that displays all information about a student in the "Student View" where I choose a studentid and then fill all the information. Thanks in advance this is my code.</p>
  
  <p>Solution 1, but not effective because i have many students and its not read from my database.</p>
  
  <pre><code>public override DataTable getStudentData()
      {    
      DataTable dt = new DataTable();
      dt.Columns.Add("StudentID");
      dt.Columns.Add("FirstName");
      dt.Columns.Add("LastName");
      dt.Columns.Add("Gender");
      dt.Columns.Add("Streetadress");
      dt.Columns.Add("ZipCode");
      dt.Columns.Add("Birthdate");
      dt.Columns.Add("StudentType");
      dt.Columns.Add("City");
      dt.Columns.Add("Country");
      dt.Columns.Add("program");
      dt.Columns.Add("PgmStartYear");
      dt.Columns.Add("credits");
      dt.Rows.Add("studentid", "Firstname", "Lastname", "Gender", "Adress", "Zipcode", "Birthdate", "Studenttype ", "City", "Country", "Programname", Startyear, credits);
  
  return dt;
  }
  </code></pre>
  
  <p>Solution that i want to be possible is something like this:</p>
  
  <pre><code>        DataTable dt = new DataTable();
          dt.Rows.Add(["studentid"].ToString());
          dt.Rows.Add(["firstname"].ToString());
          dt.Rows.Add(["lastname"].ToString());
          dt.Rows.Add(["gender"].ToString());
          dt.Rows.Add(["birthdate"].ToString());
          dt.Rows.Add(["streetadress"].ToString());
          dt.Rows.Add(["zipcode"].ToString());
          dt.Rows.Add(["country"].ToString());
          dt.Rows.Add(["city"].ToString());
          dt.Rows.Add(["studenttype"].ToString());
          dt.Rows.Add(["programname"].ToString());
          dt.Rows.Add(["year"].ToString());
  </code></pre>