First Start from the database structure.. There is no need of Join tbl PGStudents.. You can join the remaining two tables using inner join in sql..
Use the following Table Structure:
Student Table:
Field Datatype Constraint
StudentId int pk(Auto-Increment/Not-Null)
Fname varchar(50)
Lname varchar(50)
ParentGuardian tbl
Field Datatype Constraint
ParentId int pk(Auto-Increment/Not-Null)
Fname varchar(50)
Lname varchar(50)
Then next step is creating your webform..
Now For inserting Data in the Student table .. Create a page as InsertStudent.aspx.. In that include two textbox, two labels for inserting fname and lname and a button to submit the data..
Repeat the same for ParentGuardian table...
Now To display the data of the two tables use a gridview...
mr41971
Member
16 Points
78 Posts
Many to Many based web form
Nov 15, 2012 06:30 PM|LINK
The internet is useless 50% of the time.
I have a Students tbl
Student
----------------
ID
Fname
Lname
A Join tbl
PGStudents
--------------------
ID
StudentID
ParentID
And a ParentGuardian tbl
------------------------------
ID
Fname
Lname
Guru's, wise ones I beg you, I plead, please lead me to the knowledge that will allow me to build a web form for this.
I thank and wish that I could give whatever you desire.
geniusvishal
Star
14214 Points
2803 Posts
Re: Many to Many based web form
Nov 15, 2012 07:09 PM|LINK
I would say you have to go long way..
First Start from the database structure.. There is no need of Join tbl PGStudents.. You can join the remaining two tables using inner join in sql..
Use the following Table Structure:
Student Table:
Field Datatype Constraint
StudentId int pk(Auto-Increment/Not-Null)
Fname varchar(50)
Lname varchar(50)
ParentGuardian tbl
Field Datatype Constraint
ParentId int pk(Auto-Increment/Not-Null)
Fname varchar(50)
Lname varchar(50)
Then next step is creating your webform..
Now For inserting Data in the Student table .. Create a page as InsertStudent.aspx.. In that include two textbox, two labels for inserting fname and lname and a button to submit the data..
Repeat the same for ParentGuardian table...
Now To display the data of the two tables use a gridview...
My Website
www.dotnetvishal.com
mr41971
Member
16 Points
78 Posts
Re: Many to Many based web form
Nov 15, 2012 07:28 PM|LINK
Thank you for your prompt reply. The relationship is:
A student belongs to one or more Parents or Guardians
A Parents or Guardian can have one or more Students
This is indeed a many to many relationship necessitating a Join or Junction table for future queries such as:
1. Who are the children of a parent
2. Who are the parents of a student
3. How many students belong to a parent
and so on.
ramiramilu
All-Star
95463 Points
14106 Posts
Re: Many to Many based web form
Nov 16, 2012 10:34 AM|LINK
learn more about LEFT JOIN - http://www.w3schools.com/sql/sql_join_left.asp
then you can merge the results and uyou can use Count(*) to get the counts....
thanks,
JumpStart