Database 2
Create relationship using Foreign Keys Relationship between tables using foreign keys Open a windows form app named Form1 Make foreign keys Choose the table from foreign server explorer Go to foreign key and add a foreign key Give it a name FK1 ----> a code will be shown Go to code Constraint [FK1 ] Foreign key [studentid] References [student] [studentID] Add another key as a foreign key to get composite key Constraint [FK2 ] Foreign key [courseid] References [course] [courseID] Update ----> update data base
2- Generating queries Go to form Go to dataset Double click on dataset ---> a window will open Right click on this window -----> choose add ----> table add option -----> wizard will open -----> click next ----> generate query Go to tables ----> query builder. -----> add tables you want by choosing them. -----> choose from each table the attributes you want -----> the query will be automatically created -----> click ok ----->next -----> next -----> finish
Adding tables to data source Open your windows form (already created ) Go to view ----> open data source Data source -----> right click -----> configure data source with wizard -----> click wizard option ----> include tables ----> click finish