Μdi form νέες Solution Explorer Add Windows Form. Startup form Solution Explorer Properties/Application/StartupForm. Add New Item



Σχετικά έγγραφα
ΣΧΕΣΕΙΣ στην Northwind

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

VBA ΣΤΟ WORD. 1. Συχνά, όταν ήθελα να δώσω ένα φυλλάδιο εργασίας με ασκήσεις στους μαθητές έκανα το εξής: Version ΗΜΙΤΕΛΗΣ!!!!

How to register an account with the Hellenic Community of Sheffield.

The Simply Typed Lambda Calculus

Instruction Execution Times

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 19/5/2007

PortSip Softphone. Ελληνικά Ι English 1/20

4 η Εργαστηριακή Άσκηση

ΠΑΝΕΠΙΣΤΗΜΙΟ ΚΥΠΡΟΥ - ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ ΕΠΛ 133: ΑΝΤΙΚΕΙΜΕΝΟΣΤΡΕΦΗΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ ΕΡΓΑΣΤΗΡΙΟ 3 Javadoc Tutorial

Ρύθμιση σε whitelist

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 6/5/2006

2 η Εργαστηριακή Άσκηση

Οδηγίες Αγοράς Ηλεκτρονικού Βιβλίου Instructions for Buying an ebook

ΜΑΘΗΜΑ 10 Ο ΟΡΓΑΝΩΣΗ ΤΗΣ Β ΓΙΑ ΧΡΗΣΤΕΣ (NON-EXPERTS) Α. ΗΜΙΟΥΡΓΙΑ ΠΙΝΑΚΑ ΕΠΙΛΟΓΩΝ 1. TOOLS DATA UTILITIES SWITCHBOARD MANAGER YES

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

Partial Trace and Partial Transpose

department listing department name αχχουντσ ϕανε βαλικτ δδσϕηασδδη σδηφγ ασκϕηλκ τεχηνιχαλ αλαν ϕουν διξ τεχηνιχαλ ϕοην µαριανι

Εγκατάσταση λογισμικού και αναβάθμιση συσκευής Device software installation and software upgrade

Section 8.3 Trigonometric Equations

HOMEWORK 4 = G. In order to plot the stress versus the stretch we define a normalized stretch:

CYTA Cloud Server Set Up Instructions

Εργαστήριο Ανάπτυξης Εφαρμογών Βάσεων Δεδομένων. Εξάμηνο 7 ο

EE512: Error Control Coding

derivation of the Laplacian from rectangular to spherical coordinates

SPEEDO AQUABEAT. Specially Designed for Aquatic Athletes and Active People

Εργαστήριο 9. Styling with Javascript

ΜICROSOFT VISUAL STUDIO Eργ 1: Ανάπτυξη απλής εφαρµογής: Solutions, Projects, GUI, Events, Debugging. Εισαγωγή

C.S. 430 Assignment 6, Sample Solutions

1. ΕΛΕΓΧΟΙ ΕΓΚΥΡΟΤΗΤΑΣ ΣΕ ΜΙΑ ΦΟΡΜΑ

SOAP API. Table of Contents

2 Composition. Invertible Mappings

Οδηγός εκκαθάρισης ιστορικού cookies περιηγητή

Galatia SIL Keyboard Information

Δημιουργία Λογαριασμού Διαχείρισης Business Telephony Create a Management Account for Business Telephony

ΚΥΠΡΙΑΚΟΣ ΣΥΝΔΕΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY 21 ος ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ Δεύτερος Γύρος - 30 Μαρτίου 2011

(C) 2010 Pearson Education, Inc. All rights reserved.

Homework 3 Solutions

Finite Field Problems: Solutions

Phys460.nb Solution for the t-dependent Schrodinger s equation How did we find the solution? (not required)

TMA4115 Matematikk 3

Μηχανική Μάθηση Hypothesis Testing

Dynamic types, Lambda calculus machines Section and Practice Problems Apr 21 22, 2016

Other Test Constructions: Likelihood Ratio & Bayes Tests

Modbus basic setup notes for IO-Link AL1xxx Master Block

CHAPTER 25 SOLVING EQUATIONS BY ITERATIVE METHODS

6.1. Dirac Equation. Hamiltonian. Dirac Eq.

ΚΥΠΡΙΑΚΗ ΕΤΑΙΡΕΙΑ ΠΛΗΡΟΦΟΡΙΚΗΣ CYPRUS COMPUTER SOCIETY ΠΑΓΚΥΠΡΙΟΣ ΜΑΘΗΤΙΚΟΣ ΔΙΑΓΩΝΙΣΜΟΣ ΠΛΗΡΟΦΟΡΙΚΗΣ 24/3/2007

SCHOOL OF MATHEMATICAL SCIENCES G11LMA Linear Mathematics Examination Solutions

Example Sheet 3 Solutions

ΕΡΓΑΣΤΗΡΙΟ FRONT PAGE 3

Math 6 SL Probability Distributions Practice Test Mark Scheme

Συστήματα Διαχείρισης Βάσεων Δεδομένων

3.4 SUM AND DIFFERENCE FORMULAS. NOTE: cos(α+β) cos α + cos β cos(α-β) cos α -cos β

Fractional Colorings and Zykov Products of graphs

Section 7.6 Double and Half Angle Formulas

Potential Dividers. 46 minutes. 46 marks. Page 1 of 11

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 5: Component Adaptation Environment (COPE)

Σχεδιασμός Βάσεων Δεδομένων

PARTIAL NOTES for 6.1 Trigonometric Identities

New Project Windows Forms Applications

Υλοποίηση Δικτυακών Υποδομών και Υπηρεσιών: OSPF Cost

Right Rear Door. Let's now finish the door hinge saga with the right rear door

Approximation of distance between locations on earth given by latitude and longitude

Advanced Subsidiary Unit 1: Understanding and Written Response

Γράψιμο και Διάβασμα σε φύλλο του Excel

Λευτέρης Κουμάκης ΠΟΛΥΜΕΣΙΚΕΣ ΥΠΗΡΕΣΙΕΣ ΣΤΗΝ ΥΓΕΙΑ

DESIGN OF MACHINERY SOLUTION MANUAL h in h 4 0.

Inverse trigonometric functions & General Solution of Trigonometric Equations

9.09. # 1. Area inside the oval limaçon r = cos θ. To graph, start with θ = 0 so r = 6. Compute dr

Physical DB Design. B-Trees Index files can become quite large for large main files Indices on index files are possible.

Block Ciphers Modes. Ramki Thurimella

GenExis Οδηγίες προς Μαθητές

Στο εστιατόριο «ToDokimasesPrinToBgaleisStonKosmo?» έξω από τους δακτυλίους του Κρόνου, οι παραγγελίες γίνονται ηλεκτρονικά.

Section 9.2 Polar Equations and Graphs

Special edition of the Technical Chamber of Greece on Video Conference Services on the Internet, 2000 NUTWBCAM

Οδηγίες χρήσης. Registered. Οδηγίες ένταξης σήματος D-U-N-S Registered στην ιστοσελίδα σας και χρήσης του στην ηλεκτρονική σας επικοινωνία

Συντακτικές λειτουργίες

Assalamu `alaikum wr. wb.

Section 1: Listening and responding. Presenter: Niki Farfara MGTAV VCE Seminar 7 August 2016

Lecture 2. Soundness and completeness of propositional logic

Βάσεις Δεδομένων 2η εργαστηριακή άσκηση

ΠΑΝΕΠΙΣΤΗΜΙΟ ΠΕΙΡΑΙΩΣ ΤΜΗΜΑ ΠΛΗΡΟΦΟΡΙΚΗΣ. Βάσεις Δεδομένων (4 ο εξάμηνο) Εργαστήριο MySQL #2

Δίκτυα Επικοινωνιών ΙΙ: OSPF Configuration

ΤΛΟΠΟΙΗΗ STANDALONE ΕΦΑΡΜΟΓΗ ΚΡΑΣΗΕΩΝ ΔΩΜΑΣΙΩΝ ΞΕΝΟΔΟΧΕΙΟΤ ΜΕ C-SHARP ΚΑΙ SQL-SERVER

Numerical Analysis FMN011

Όλγα Κασσώτη

Matrices and Determinants

Οι αδελφοί Montgolfier: Ψηφιακή αφήγηση The Montgolfier Βrothers Digital Story (προτείνεται να διδαχθεί στο Unit 4, Lesson 3, Αγγλικά Στ Δημοτικού)

Mean bond enthalpy Standard enthalpy of formation Bond N H N N N N H O O O

Code Breaker. TEACHER s NOTES

Πώς εκτυπώνουμε μία λίστα από εγγραφές μίας Access database

ΦΥΛΛΟ ΕΡΓΑΣΙΑΣ Α. Διαβάστε τις ειδήσεις και εν συνεχεία σημειώστε. Οπτική γωνία είδησης 1:.

Concrete Mathematics Exercises from 30 September 2016

Business English. Ενότητα # 9: Financial Planning. Ευαγγελία Κουτσογιάννη Τμήμα Διοίκησης Επιχειρήσεων

Lecture 2: Dirac notation and a review of linear algebra Read Sakurai chapter 1, Baym chatper 3

The challenges of non-stable predicates

Πρόβλημα 1: Αναζήτηση Ελάχιστης/Μέγιστης Τιμής

ΓΡΑΜΜΙΚΟΣ & ΔΙΚΤΥΑΚΟΣ ΠΡΟΓΡΑΜΜΑΤΙΣΜΟΣ

Transcript:

Μdi form Μέσα σε ένα project ( *.vbproj) µπορώ να προσθέσω µια ή περισσότερες νέες φόρµες(*.vb) από το επιθυµητό template. Αυτό µπορεί να γίνει από τον Solution Explorer µε κλικ στο όνοµα του Project και Add/Windows Form. Μια από αυτές τις φόρµες θα είναι η πρώτη του έργου (Startup form). Αυτό µπορεί να γίνει και από τον Solution Explorer µε κλικ στο όνοµα του Project και Properties/Application/StartupForm. Το template µιας φόρµας µπορεί να είναι π.χ. (Add New Item/Common Items/) Windows Form Mdi Parent Form Control κ.α. To 2 ο template δηµιουργεί µια MDI (Multiple Document Interface) φόρµα (parent), που επιτρέπει στον χρήστη να δουλέψει µε πολλά documents (child) ταυτόχρονα. Κάθε document εµφανίζεται µέσα στο δικό του window, που ελέγχεται από τnν parent form. ηµιουργώ ένα project έστω MDItest µε 2-3 φόρµες Windows Form (Form1, Form2, Form3) και µια φόρµα Mdi Parent Form Control (MDIParent1) την οποία θα παρατηρήσω και θα δηµιουργήσω µια παρόµοια (MakeΜDI) από µια απλή φόρµα (Form1). Μετονοµάζω την Form1 σε MakeMdi και την κάνω και start up. Για να κάνω την Form1 Μdi (parent) φόρµα πρέπει στο design της φόρµας Να γίνει True ή ιδιότητα ΙsMdiContainer και να εισαχθεί στην φόρµα (µέσω του Toolbox) ένα MenuStrip Control Παρατηρείστε το µικρό βελάκι στην πάνω δεξιά γωνία του control MenuStrip (Στα περισσότερα control υπάρχει αυτό το βελάκι: smart-tag glyph ( )) [1]

ιαλέγω Insert Standard Items. Μπήκε το standard µενού File/Edit/Tools/Help (αλλά οι επιλογές δεν έχουν λειτουργικότητα πρέπει να τις προγραµµατίσουµε). Το τρέχουµε (F5/Start debugging). (Aν θέλουµε βάζουµε και ένα ToolStrip control). Κάνουµε την MdiParent1 φόρµα StartupForm και το τρέχουµε (F5), οι επιλογές της έχουν κάποια λειτουργικότητα. Επιστρέφουµε στο design της. ιπλό κλικ στο µενού File/New της MdiParent1 φόρµας να δούµε το πρόγραµµα. (Απόσπασµα από τον κώδικα της MDIParent1) Public Class MDIParent1 Private m_childformnumber As Integer Private m_childformnumber As Integer Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewToolStripButton.Click, NewWindowToolStripMenuItem.Click ' Create a new instance of the child form. Dim ChildForm As New System.Windows.Forms.Form ' Make it a child of this MDI form before showing it. ChildForm.MdiParent = Me m_childformnumber += 1 ChildForm.Text = "Window " & m_childformnumber ChildForm.Show() End Sub ' End Class Στην µεταβλητή m_childformnumber κρατάει σειριακό νούµερο για τον τίτλο της φόρµας child (Windows 1, 2, 3, 4..). 1) ηµιουργεί µεταβλητή ChildForm για την νέα φόρµα 2) Λέει ότι το MdiParent της ChildForm είναι η φόρµα (Μe) MDIParent1 (The Me keyword is used here to refer to the MDIParent1.vb form, and you ll see this shorthand syntax when a reference is being made to the current instance of a class or structure in which the code is executing.) 3) είχνει την ChildForm Εξάσκηση Προγραµµατίστε τa υποµενού Show/Form2 & Οpen/Form3 να ανοίγουν τις φόρµες Form2 και Form3 της δικής σας MakeMdi φόρµας. [2]

Database Programming ADO.NET is a set of computer software components that programmers can use to access data and data services. It is a part of the base class library that is included with the Microsoft.NET Framework. It is commonly used by programmers to access and modify data stored in relational database systems, though it can also access data in non-relational sources. ADO.NET is sometimes considered an evolution of ActiveX Data Objects (ADO) technology, but was changed so extensively that it can be considered an entirely new product. (Northwind.mdb) We ll create a typed DataSet with the three basic tables of the Northwind.mdb database: Products, Categories, and Suppliers. Create a new project, the DataSetOperations project (Windows Form Ap). Open the Data menu and choose the Add New Data Source command. You will see the Data Source Configuration Wizard, In the first dialog box of the wizard, you ll be asked to select the data source type, which can be a database, a service (such as a web service), or an object [3]

Select the Database icon and click the Next button. In the next dialog box of the wizard, the Choose a DataBaseModel dialog box Select the Dataset icon and click the Next button. In the next dialog box of the wizard, the Choose Your Data Connection dialog box shown you must specify a connection string for the database you want to use.. Click the New Connection button to create a new connection Once connected to the server, you can select the desired database from a ComboBox control. Click the OK button to close the Add Connection dialog box and then click Next again and you will see a dialog box with the default connection name: +NorthwindConnectionString Click Next again and you will see the Choose Your Database Objects dialog box, where you can select the tables and columns you want to load to the DataSet. you can specify the name of the DataSet that will be generated for you: NorthwindDataSet. In the Data Sources window, you will see a tree that represents the tables in the DataSet. We choose 3 tables Product,Category and Suppliers The DataSet contains three DataTables, and each DataTable is made of the columns you selected in the wizard. The interesting part of this tree is that it contains the Products table twice: in the first level along with the Categories table, and once again under the Categories and Suppliers table. [4]

The Products table on the first level represents the entire table, the nested ones represent the products linked to their categories and their suppliers respectively. Click Finish to close the wizard and create the DataSet, which will be added automatically to the Solution Explorer window. Design and use typed DataSets. Typed DataSets are created with visual tools at design time and allow you to write type-safe code. A typed DataSet is a class created by the wizard on the fly and it becomes part of the project (* System<-Data<-DataSet<-DataTable<-DataColumn<-Constraint...*) Περιέχει τους επιλεγμένους πίνακες και τις σχέσεις τους. Μπορεί να τροποποιηθεί (Data Source για επιπλέον πίνακες/data Set Designer για επιπλέον πίνακες ή queries.) A dataset contains no actual data by default. Filling a dataset with data actually refers to loading data into the individual DataTable objects that make up the dataset. You fill the data tables by executing TableAdapter queries, or executing data adapter (for example, SqlDataAdapter) commands. When you fill a dataset with data, various events are raised, constraints are checked, and so on. Designing Data-Driven Interfaces the EasyWay [5]

Let Visual Studio perform the binding for you: 1. Make the Form3 form, the project s Startup object. To display the rows of the Products table on a DataGridView control, open the DataSources window and select the Products table. As soon as you select it, an arrow appears next to its name. Click this arrow to open a drop-down list with the binding options for the DataTable. The DataTable can be bound to the following: A DataGridView control, which will display all rows and all columns of the table A number of TextBox controls (the Details option), one for each column A ListBox or ComboBox control, which will display a single column of all rows 2. Select the DataGridView option and then drop the Products DataTable on the form. και F5 (debug) The editor will create a DataGridView control and bind it to the Products DataTable. In addition, it will create a toolbar at the top of the form with a few navigational and editing buttons, Αρχή-Πίσω ProductsBindingNavigator Μπροστά Τέλος Προσθήκη-Διαγραφή Σώσιμο ΕΓΓΡΑΦΩΝ πίνακα. [6]

The toolbar contains one button for deleting rows (the button with the X icon) and one button for submitting the edits to the database (the button with the disk icon). The Filter,Find, and Refresh Data buttons were not generated by the editor.. The designer will also generate the following components, which will appear in the Components tray: NorthwindDataSet The typed DataSet for the data specified with the Data Source Configuration Wizard. ProductBindingSource A BindingSource object for the Products table. ProductsTableAdapter An enhanced DataAdapter that exposes the methods for reading data from the database and submitting the changes made at the client back to the database. The methods of the TableAdapter object know how to handle rows of the specific type, and not any DataRow object. TableAdapterManager This encapsulates the functionality of all TableAdapter objects on the form. If you drop additional tables on the form, the editor will create the corresponding TableAdapter for each one. ProductsBindingNavigator This component represents the toolbar added to the form. The toolbar is a ToolStrip control with custom items and the appropriate code. The navigational tools generated by the editor are rather primitive, and you can remove them from the control. Just keep the code for the Save button, which you ll need if your application allows editing of the data. 1. Look at the auto generated Form3 code Public Class Form3 [7]

The Click event of the Save button on the toolbar, calls the TableAdapterManager class s UpdateAll method. Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductsBindingNavigatorSaveItem.Click Me.Validate() Me.ProductsBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.NorthwindDataSet) End Sub In the form s Load event handler, the Products DataTable is filled with a call to the Products-TableAdapter class s Fill method. Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ' Me.TableAdapterManager.ProductsTableAdapter.Adapter.ContinueUpdateOnError = True End Sub End Class Me.ProductsTableAdapter.Fill(Me.NorthwindDataSet.Products) 2. F5 (debug) and change a few names, set a couple of prices to negative values, set a product s category to an invalid category ID (any value exceeding 7 is invalid), add a couple of new products (they will be assigned negative IDs, as expected), and delete some products Can you delete rows from the Products table? They re all referenced by the Order Details table, but this table doesn t exist in the DataSet, so it s perfectly legal to delete products in the context of the DataSet. When the edits are submitted to the database, the deletions will be rejected, of course. Insert the following method in front of the statement that calls the UpdateAll method: Me.TableAdapterManager.ProductsTableAdapter.Adapter.ContinueUpdateOnError = True Run the application again, edit the data on the grid, and submit the changes to the database. This time the application won t crash with an error message. Binding Combo boxes Στην παρακάτω φόρμα υπάρχει το πεδίο SupplierID που ανήκει στον Πίνακα Products. To πεδίο είναι Combobox και αν θέλουμε να έχουμε μέσα στην dropdown λίστα του όλους τους υπάρχοντες προμηθευτές θα πρέπει να γίνει bound το Combobox. Εύκολα γίνεται αυτό αν πάρουμε (από το DATASOURCES) τον πίνακα των προμηθευτών (Suppliers) και τον σύρουμε μέσα στο Combobox. Τότε όπως φαίνεται στην Παρακάτω εικόνα χρησιμοποιεί data bound items με ιδιότητες: DataSource : από που το Combobox θα πάρει δεδομένα (είναι το SuppliersBindingSource, μιας και θέλουμε να έχει όλα τα ονόματα των προμηθευτών. [8]

DisplayMember: η στήλη που θέλετε να εμφανίζεται στο Combobox (π.χ. η στήλη Όνομα Προμηθευτή/ CompanyName του πίνακα Supplier). ValueMember : η στήλη που δεσμεύει τα περιεχόμενα του Combobox στο πίνακα (δηλ. η στήλη SupplierID του πίνακα Supplier). SelectedValue : η matching στήλη of the child table (αυτή είναι το SupplierID από το ProductsBindingSource). The control will automatically select the row of the Supplier table whose SupplierID matches the SupplierID column of the Products DataTable. Binding Hierarchical Tables Build an interface to display categories and products on two DataGridView Controls. You ll create two DataGridView controls linked together. Follow these steps: 1. Start a new project (it s the LinkedDataTables project), and create a new DataSet that contains the Products, Categories, and Suppliers tables, named DS. 2. In the Data Sources window, select each table and set its binding option to DataGridView. [9]

3. Drop the Categories table on the form. The editor will place an instance of the DataGrid- View control on the form and will bind it to the Categories table. It will also create a BindingNavigator object, which we don t really need, so you can delete it. When you drop multiple tables on a form, the editor generates a single toolbar. The navigational buttons apply to the first DataGridView control, but the Save button submits the changes made in all DataTables 4. Locate the Products table under the Categories table in the Data Sources window and drop it onto the form. If you drop the Products table of the original DataSet onto the form,you ll end up with two grids that are independent of one another. For a more meaningful interface, you must link the two grids, so that when the user selects a category in the upper grid, the corresponding tables are shown automatically in the lower grid. The Products table under the Categories table in the data source represents the rows of the Products table that are related to each row of the Categories table. In the Data Sources window select Edit DataSet With Designer to see the DataSet Designer window. (or from NorthwindDataSet.xsd - to *.xml σχήμα ). Right-click the line that connects the Products and Categories tables (this line represents the relationship between the two tables) and select Edit Relation to open the Relation dialog box: Choose what to create: Relation & Foreign Foreign Only Relation Only The Products- Categories relation is marked as Relation Only. [10]

In the database, this is a relation and a foreign key constraint. The relation simply relates the two tables if their CategoryID fields match. Most importantly, the constraint won t let you insert a product that points to a nonexisting category, or delete a category that has related rows in the Products table. Check the radio button Both Relation And Foreign Key Constraint, and then close the dialog box. Foreign key constraints are subject to three rules: the Update, Delete, and Accept/Reject rules. These rules determine what should happen when a parent row is removed from its table (the Delete rule), when a parent ID is modified (the Update rule), and when users accept or reject changes in the DataSet (the last rule). A rule can be set to: None (no action is taken, which means that a runtime exception will be thrown), Cascade (the child rows are updated or deleted) SetNull (the foreign keys of the related rows are set to Null), and SetDefault (the foreign keys of the related rows are set to their default value). We usually don t change the rules of a relationship in the DataSet, unless you ve used rules in the database. Leave them set to None and run the application again. You should avoid setting the Delete and Update rules to Cascade, because this can lead to irrecoverable errors. If you delete a category, for example, it will take with it the related products, and each deleted product will take with it the related rows in the Order Details table. A simple error can ruin the database.there are other situations, which aren t as common, where the Cascade rule can be used safely. When you delete a book in the Pubs database, for example, you want the book s entries in the TitleAuthors table to be removed as well. No rows in the Authors table will be removed, because they re primary, and not foreign, keys in the relation between the TitleAuthors and Authors tables. Using the BindingSource as a Data Source To link the two DataGridView controls, you must create a BindingSource object for each one. The BindingSource class encapsulates a data source and is itself a data source. Initialize an instance of this class by setting its DataSource and DataMember properties for the Categories table: Dim categoriesbs As New BindingSource categoriesbs.datasource = DS categoriesbs.datamember = Categories Dim productsbs As New BindingSource productsbs.datasource = categoriesbs productsbs.datamember = CategoriesProducts /relation [11]

We also can write a code like follow: Public Class Form4 'ORISMOS 3 DataADAPTER objects Dim CategoriesTA As New NorthwindDataSetTableAdapters.CategoriesTableAdapter Dim SuppliersTA As New NorthwindDataSetTableAdapters.SuppliersTableAdapter Dim ProductsTA As New NorthwindDataSetTableAdapters.ProductsTableAdapter 'ΟΡΙΣΜΟΣ DataSet Dim DS As New NorthwindDataSet Private Sub CategoriesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Me.Validate() Me.CategoriesBindingSource.EndEdit() Me.TableAdapterManager.UpdateAll(Me.NorthwindDataSet) End Sub Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'NorthwindDataSet.Categories' table. You can move, or remove it, as needed. Me.CategoriesTableAdapter.Fill(Me.NorthwindDataSet.Categories) End Sub This is a button named BttnPopulate Private Sub BttnPopulate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BttnPopulate.Click Dim categories As Integer = CategoriesTA.Fill(DS.Categories) Dim suppliers As Integer = SuppliersTA.Fill(DS.Suppliers) Dim products As Integer = ProductsTA.Fill(DS.Products) 'prod We have a (multiline) textbox to show rows of data using method AppendText Dim prod As NorthwindDataSet.ProductsRow For Each prod In DS.Products.Rows TextBox1.AppendText(prod.ProductName & vbtab & prod.unitprice.tostring("#,###.00") & vbcrlf) Next End Sub End Class [12]