CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.

Slides:



Advertisements
Similar presentations
Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
Advertisements

 Open the Paradise.exe file  Application displays records in the Books database  Allows the store manager to enter an author’s name (or part of a name)
Chapter 14.3 LINQ to SQL Programming in Visual Basic 2010: The Very Beginner’s Guide by Jim McKeown Databases – Part 3.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ 1 Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
Chapter 18 Databases and LINQ Visual C# 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Some Basic Database Terminology
Chapter 10 - VB.Net by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
Databases and LINQ Visual Basic 2010 How to Program 1.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
CPSC 203 Introduction to Computers T59 & T64 By Jie (Jeff) Gao.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter 15: Using LINQ to Access Data in C# Programs.
 SQL Server Express provides many features of Microsoft’s full (fee- based) SQL Server product, but has some limitations:  a maximum database size.
Copyright © 2012 Pearson Education, Inc. Chapter 11 Databases.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Thirteen Working with Access Databases and LINQ.
Connecting to Data Sources Using ADO.NET Dr. Awad Khalil Computer Science & Engineering Department AUC.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
Microsoft Access You will need a pen/pencil.. What is Microsoft Access? Access is a database management system.  Create a database, add/change delete.
 2006 Pearson Education, Inc. All rights reserved Database, SQL and ADO.NET.
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
1 Chapter 12 – Web Applications 12.1 Programming for the Web, Part I 12.2 Programming for the Web, Part II 12.3 Using Databases in Web Programs.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
SESSION 3.1 This section covers using the query window in design view to create a query and sorting & filtering data while in a datasheet view. Microsoft.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Databases with LINQ. LINQ to SQL LINQ to SQL uses LINQ syntax to query databases. LINQ to SQL classes are automatically generated by the IDE’s LINQ to.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved. 2 Revised by Dr. T. Tran for CSI3140.
3 Copyright © 2004, Oracle. All rights reserved. Working in the Forms Developer Environment.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 25.1 Test-Driving the ATM Application 25.2.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections UTPA – Fall 2011.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
Databases and ADO.NET Programming Right from the Start with Visual Basic.NET 1/e 11.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
 2009 Pearson Education, Inc. All rights reserved Databases and LINQ to SQL.
CPSC 203 Introduction to Computers T97 By Jie (Jeff) Gao.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ – Exercises 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
LINQ to DATABASE-2.  Creating the BooksDataContext  The code combines data from the three tables in the Books database and displays the relationships.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Binding to ListBox and ComboBox Controls List and combo boxes are frequently.
Database (Microsoft Access). Database A database is an organized collection of related data about a specific topic or purpose. Examples of databases include:
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Visual Basic 2010 How to Program
The University of Texas – Pan American
Brief description on how to navigate within this presentation (ppt)
CSCI 3327 Visual Basic Chapter 8: Introduction to LINQ and Collections
CIS16 Application Programming with Visual Basic
Chapter 10 Accessing Database Files
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Presentation transcript:

CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011

Objectives In this chapter, you will –Learn the relational database model –Get familiar with using LINQ to retrieve and manipulate data from a database –Know how to add data sources to project, create LINQ to SQL classes, and use data binding to move data between GUI controls and databases –Learn how to create Master/Detail views to select a record and display its details 2

Example 12.20: TitleQueries.vb URL: – p_2010/codeexamples.htmlhttp://media.pearsoncmg.com/ph/esm/deitel/vb_ht p_2010/codeexamples.html GUI in the next page 3

Dynamically Binding Query Results 4

Creating the Display Query Results Step 1: Creating the Project –Create a new Windows Forms Application named DisplayQueryResult –Rename the source file to TitleQueries.vb. –Set the Form’s Text property to Display Query Results Step 2: Creating the LINQ to SQL Classes –Add the Books database to the project –Generate the LINQ to SQL classes 5

Creating the Display Query Results (cont'd) Step 3: Creating a DataGridView to Display the Titles Table –Create the data source and the DataGridView. –Select the Title class (rather than the Author class) as the data source –Drag the Title node from the Data Sources window onto the form 6

Creating the Display Query Results (cont'd) Step 4: Adding a ComboBox to the Form –In Design view, add a ComboBox named queriesComboBox below the DataGridView on the Form –Open the ComboBox’s String Collection Editor by right clicking the ComboBox and selecting Edit Items All titles Titles with 2008 copyright Titles ending with "How to Program" 7

Coding the Display Query Results 8

Coding the Display Query Results (cont'd) 9

Retrieving Data from Multiple Tables with LINQ Join two tables with LINQ Example 12.22: –URL: vb_htp_2010/codeexamples.htmlhttp://media.pearsoncmg.com/ph/esm/deitel/ vb_htp_2010/codeexamples.html 10

Retrieving Data from Multiple Tables with LINQ (cont'd) 11

Other LINQ Queries Let query operator –Declare a new variable in an LINQ query 12

Create the Master/Detail GUI 13

Create the Master/Detail GUI (cont'd) 14

Steps to Create the Master/Detail GUI Step 1: Creating the Project –Create a new Windows Forms Application called MasterDetail –Name the source file Details.vb and set the Form’s Text property to Master/Detail Step 2: Creating LINQ to SQL Classes –Add the Books database –Create the LINQ to SQL classes to interact with the database 15

Steps to Create the Master/Detail GUI (cont'd) Step 3: Creating GUI Elements –Add two Labels and two ComboBoxes to the top of the Form 16

Steps to Create the Master/Detail GUI (cont'd) Create a DataGridView, booksDataGridView, to hold the details that are displayed –Do not automatically create it by dragging a data source from the Data Sources window –Instead, drag the DataGridView from the Toolbox –Add two BindingSources, namely titleBindingSource and authorBindingSource, from the Data section of the Toolbox, one for information from the Titles table and one for information from the Authors table 17

Master/Detail GUI Nested classes –Class AuthorBinding is intended for use only in this example –So it is defined inside class Details—it’s a so- called nested class 18

Master/Detail GUI (cont'd) DisplayMember = "Name" –Tell the ComboBox to use the Name property of the objects in its DataSource to determine what text to display for each item 19

Master/Detail GUI (cont'd) 20

Exercises A table in a relational database consists of ____ and ____ in which values are stored. The _____uniquely identifies each row in a relational database table. A relational database can be manipulated in LINQ to SQL via a(n) ____ object, which contains properties for accessing each table in the database. Merging data from multiple relational database tables is called _____ the data. A(n) is a column (or groups of column) in a relational database table that matches the primary-key column (groups of column) in another table. 21

True / False Statements Providing the same value for a foreign key in multiple rows causes the DBMS to report an error. Providing a foreign-key value that does not appear as a primary-key value in another table is an error. The result of a query can be sorted in ascending or descending order. LINQ to SQL automatically saves changes made back to the database. 22

23