title: Display data from a table on a C# winform application
body: <p>I need some help displaying data from a table onto the winform. Normally this could be done using the datagridview but to my understanding datagridvide either displays the whole content of the table or I can use a filter function to display data that matches the filter.</p>
  
  <p>The  issue that I am currently facing is, I have a table called book_issued which contains the details of all book issued to students, each student has an unique regid.</p>
  
  <p>I have a login form which gets the value of the regid of a student when he logs in, and then directs them to another form which is supposed to display a list of all the books the student has been issued.</p>
  
  <p>To achieve that I am running the sql query</p>
  
  <pre><code>"SELECT * FROM book_issued WHERE regid = @regid"
  </code></pre>
  
  <p>I am skipping the process of passing the parametarized value and reading the data from the datareader. </p>
  
  <p>My problem is displaying this data on the form, some help would be greatly appreciated</p>
  
  <p>Stupid code that has nothing to do with the problem but ppl would vote down the question without it</p>
  
  <pre><code> private void student_Load(object sender, EventArgs e)
          {
              // TODO: This line of code loads data into the 'libDataSet8.issue' table. You can move, or remove it, as needed.
              this.issueTableAdapter1.Fill(this.libDataSet8.issue);
              // TODO: This line of code loads data into the 'libDataSet7.issue' table. You can move, or remove it, as needed.
              //this.issueTableAdapter.Fill(this.libDataSet7.issue);
              //// TODO: This line of code loads data into the 'libDataSet6.books' table. You can move, or remove it, as needed.
              //this.booksTableAdapter.Fill(this.libDataSet6.books);
  
          }
  
          private void nameToolStripButton_Click(object sender, EventArgs e)
          {
              try
              {
                  this.booksTableAdapter.name(this.libDataSet6.books, nameToolStripTextBox.Text);
              }
              catch (System.Exception ex)
              {
                  System.Windows.Forms.MessageBox.Show(ex.Message);
              }
  
          }
  
          //Get Student Details
          private void student_details(string input)
          {
              query = "SELECT * FROM student WHERE regid = @regid";
              string conString = Properties.Settings.Default.libConnectionString;
              using (SqlCeConnection conn = new SqlCeConnection(conString))
              {
                  conn.Open();
                  using (SqlCeCommand cmd = new SqlCeCommand(query, conn))
                  {
                      cmd.Parameters.AddWithValue("@regid", input);
                      cmd.ExecuteNonQuery();
  
                      SqlCeDataReader reader = cmd.ExecuteReader();
  
                      while (reader.Read())
                      {
                          dob = reader["dob"].ToString();
                          sbook = Convert.ToInt32(reader["book"].ToString());
                          fine = Convert.ToDouble(reader["fine"].ToString());
                      }
                      string temp = dob.Substring(5, 4);
                      int years = DateTime.Now.Year - Convert.ToInt32(temp);
  
                      sage = years;
  
                  }
              }
  
          }
          //Method to validate user inputs
          private bool ValidateISBNi()
          {
              bool bStatus = true;
              if (isbni.Text == string.Empty)
              {
                  errorProvider2.SetError(isbni, "");
                  errorProvider1.SetError(isbni, "Please Enter ISBN code");
                  bStatus = false;
              }
              else
              {
                   query = "SELECT * FROM books WHERE isbn = @isbn";
                   string conString = Properties.Settings.Default.libConnectionString;
                   using (SqlCeConnection conn = new SqlCeConnection(conString))
                   {
                       conn.Open();
                       using (SqlCeCommand cmd = new SqlCeCommand(query, conn))
                       {
                           cmd.Parameters.AddWithValue("@isbn", isbni.Text);
                           cmd.ExecuteNonQuery();
  
                           SqlCeDataReader reader = cmd.ExecuteReader();
  
                           while (reader.Read())
                           {
                               counter = 1;
                           }
  
                       }
                   }
                   if (counter == 1)
                   {
                       errorProvider1.SetError(isbni, "");
                       errorProvider2.SetError(isbni, "Good");
                       counter = 0;
                   }
                   else
                   {
                       errorProvider2.SetError(isbni, "");
                       errorProvider1.SetError(isbni, "Invalid ISBN code");
                       bStatus = false;
                   }
              }
              return bStatus;            
          }
  
          private bool ValidateISBNr()
          {
              bool bStatus = true;
              if (isbni.Text == string.Empty)
              {
                  errorProvider2.SetError(isbnr, "");
                  errorProvider1.SetError(isbnr, "Please Enter ISBN code");
                  bStatus = false;
              }
              else
              {
                  query = "SELECT * FROM issue WHERE isbn = @isbn AND rgid = @rgid";
                  string conString = Properties.Settings.Default.libConnectionString;
                  using (SqlCeConnection conn = new SqlCeConnection(conString))
                  {
                      conn.Open();
                      using (SqlCeCommand cmd = new SqlCeCommand(query, conn))
                      {
                          cmd.Parameters.AddWithValue("@isbn", isbnr.Text);
                          cmd.Parameters.AddWithValue("@rgid", Variables.regid);
                          cmd.ExecuteNonQuery();
  
                          SqlCeDataReader reader = cmd.ExecuteReader();
  
                          while (reader.Read())
                          {
                              counter = 1;
                          }
  
                      }
                  }
                  if (counter == 1)
                  {
                      errorProvider1.SetError(isbnr, "");
                      errorProvider2.SetError(isbnr, "Good");
                      counter = 0;
                  }
                  else
                  {
                      errorProvider2.SetError(isbni, "");
                      errorProvider1.SetError(isbni, "Invalid ISBN code");
                      bStatus = false;
                  }
              }
              return bStatus;            
          }
  
  
          private void isbni_Validating(object sender, CancelEventArgs e)
          {
              ValidateISBNi();
          }
  
          private void isbnr_Validating(object sender, CancelEventArgs e)
          {
              ValidateISBNr();
          }
  
  
          private void button1_Click(object sender, EventArgs e)
          {
              bool vissue;
              vissue = ValidateISBNi();
              if (vissue)
              {
  
              }
          }
  
          private void button3_Click(object sender, EventArgs e)
          {
              this.Close();
          }
  
          private void groupBox3_Enter(object sender, EventArgs e)
          {
  
          }
  
  
      }
  }
  </code></pre>
  
  <p>There added a bunch of random codes does that help ne1? I didnt think it would that was why i didnt post it in the first place</p>