This document discusses .NET database objects and how to work with databases in .NET applications. It describes how to create a Windows Forms application with a dataset and table adapter to interact with a SQL database. It explains primary keys, foreign keys, and how to perform common database operations like selecting, inserting, updating and deleting data using .NET objects like the dataset, table adapter, and binding navigator.
2. What is a Database?More correct it is a Database Management System (DBMS) Read moreA persistent container of DataStores any data type (Integer, String, Boolean, DateTime, Image,)Since the 1970sStores data in tablesDatabaseDatabase table: Person
7. Primary Key?A primary key is the unique reference to that rowIn never nullA foreign key can be a reference to a primary key in another tableprimary keys Person has a pair of shoes, but the shoe is stored in the Shoe table. Shoe column must have the same type as primary key in Shoe tableforeign key
8. Let the Fun Begin!Hit the Data menu > Show Data SourcesDrag-n-drop the table to the Windows Form and a DB-connected DataGridView is addedDetails show up too, if chosen
10. Howdo I?Add a new row?PersonDataSet.PersonRow personRow;personRow = personDataSet.Person.NewPersonRow();personRow.ID = index;personRow.Name = name;personRow.Age = age;personRow.Gender = gender;this.personDataSet.Person.Rows.Add(personRow); validate and write to databasethis.Validate();this.personBindingSource.EndEdit();this.tableAdapterManager.UpdateAll(this.diagramDataSet);
11. Howdo I?Delete row?PersonDataSet.PersonRow oldPersonRow;oldPersonRow = personDataSet.Person.FindBypersonID(index);oldPersonRow.Delete(); and dont forget to validate and write the change to database
12. Read from the database?Read database rowPersonDataSet.PersonRow personRow;personRow = personDataSet.Person.FindBypersonID(index);int id = personRow.ID;String name = personRow.Name;int age = personRow.Age;String gender = personRow.Gender;slideShow.EndEdit();