locked
ASP.NET Loop RRS feed

  • Question

  • User-459659403 posted

    I have two tables "people" and "training". I need to get on the people table the names of each people and get on the training table the trainings of those peolple. As I'm new on the asp.net I really don't know how to do that. Anyone can help?

    Tuesday, March 20, 2018 3:16 PM

All replies

  • User475983607 posted

    I have two tables "people" and "training". I need to get on the people table the names of each people and get on the training table the trainings of those peolple. As I'm new on the asp.net I really don't know how to do that. Anyone can help?

    This is a database design question.  Create a third table that matches the People (primary key) with the Training (primary key). This is called a many-to-many relationship.

    How you go about this depends on the data access technology you are using which is not clear from your question.

    https://docs.microsoft.com/en-us/sql/analysis-services/lesson-5-3-defining-a-many-to-many-relationship

    Tuesday, March 20, 2018 3:28 PM
  • User-459659403 posted

    Thank you for the reply, I need to show it in a gridview on a web form like trainings.aspx.

    Tuesday, March 20, 2018 3:59 PM
  • User475983607 posted

    Thank you for the reply, I need to show it in a gridview on a web form like trainings.aspx.

    Go through the getting started tutorials from the link link above.

    https://www.asp.net/web-forms

    Tuesday, March 20, 2018 4:06 PM
  • User-459659403 posted

    Let me try to explain a little better.

    One Table called people.

    Other table called trainings.

    I understood I have to create the third table with the results.

    I have a listbox on a web form listing courses from other table called courses.

    It has to go through the people table catch each "name" go to trainings and look if it finds the course I have choose on the listbox for that name in the peolpe table .

    If it doesn't find the course in the trainings table for that name in the people table then it is going to be the result. Sorry about my bad english.

    Tuesday, March 20, 2018 4:59 PM
  • User475983607 posted

    Let me try to explain a little better.

    One Table called people.

    Other table called trainings.

    I understood I have to create the third table with the results.

    I have a listbox on a web form listing courses from other table called courses.

    It has to go through the people table catch each "name" go to trainings and look if it finds the course I have choose on the listbox for that name in the peolpe table .

    If it doesn't find the course in the trainings table for that name in the people table then it is going to be the result. Sorry about my bad english.

    You're asking about fundamentals that are covered in the Getting Started Tutorials.  Go through a few tutorials and see if that helps answer your questions. 

    If you still need help after going through the tutorials, post your code and DB schema include a description of the problem you are trying to solve and expected results.

    Tuesday, March 20, 2018 5:05 PM
  • User-1838255255 posted

    Hi fpedro,

    According to your description, as far as i know, you could check this tutorial to design database and select data: 

    SQL INNER JOIN Keyword: 

    https://www.w3schools.com/sql/sql_join_inner.asp 

    About how to show database data in gridview , please check the following sample tutorial: 

    Display data in GridView from database in ASP.Net using C# and VB.Net: 

    https://www.aspsnippets.com/Articles/Display-data-in-GridView-from-database-in-ASPNet-using-C-and-VBNet.aspx 

    Best Regards,

    Eric Du 

    Wednesday, March 21, 2018 9:18 AM