Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.

Slides:



Advertisements
Similar presentations
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Advertisements

Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
 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)
BIM211 – Visual Programming Database Operations 1.
BIM313 – Advanced Programming Database Operations 1.
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.
1 Web-Enabled Decision Support Systems Advance Topics in Database Connectivity Prof. Name Position (123) University Name.
Chapter 12: Using ADO.NET 2.0 Programming with Microsoft Visual Basic 2005, Third Edition.
Integrating Access with the Web and with Other Programs.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
CSCI 3328 Object Oriented Programming in C# Chapter 12: Databases and LINQ 1 Xiang Lian The University of Texas – Pan American Edinburg, TX 78539
Copyright © 2014 Pearson Education, Inc. Chapter 10 Working with Databases.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Some Basic Database Terminology
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Databases and LINQ Visual Basic 2010 How to Program 1.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Chapter 11 Introduction to Database Processing. Class 11: Database Processing Use a Visual Studio Wizard to establish a database connection used to load.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 10 Working with Databases.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter 15: Using LINQ to Access Data in C# Programs.
Advanced Visual Basic th Edition Chapter 3: Using SQL Server Databases (c) 2007 Pearson Education Inc. All rights reserved. You may modify and copy.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
1 Databound Controls. 2 Objectives You will be able to use design time data binding to display and update SQL Server database data without writing any.
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.
1 Working with MS SQL Server Textbook Chapter 14.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Thirteen Working with Access Databases and LINQ.
 2006 Pearson Education, Inc. All rights reserved Database, SQL and ADO.NET.
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide STARTING OUT WITH Visual Basic 2008 FOURTH EDITION Tony Gaddis.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
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.
Making the Most of WinForms 2.0 Data Binding Rajiv Sodhi Microsoft India.
Ch. 101 Database Management An Introduction to Databases.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
INTRODUCTION TO ACCESS. OBJECTIVES  Define the terms field, record, table, relational database, primary key, and foreign key  Create a blank database.
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.
Copyright © 2014 Pearson Education, Inc. Chapter 10 Working with Databases.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Address Book Application Introducing Database Programming.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 8 1 Microsoft Office Access 2003 Tutorial 8 – Integrating Access with the.
Understand Databound Controls Windows Development Fundamentals LESSON 4.2A.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
Creating SQL Database file And Displaying a Database Table in a DataGridView.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Binding to ListBox and ComboBox Controls List and combo boxes are frequently.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
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
Basic Database Concepts
Brief description on how to navigate within this presentation (ppt)
Working with Databases
Microsoft Office Access 2003
Microsoft Office Access 2003
CIS16 Application Programming with Visual Basic
Chapter 10 ADO.
Database Applications
Working With Databases
Chapter 10 Accessing Database Files
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Chapter 9 Working with Databases

Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How to write Visual Basic applications that interact with databases – How to use a DataGridView control and display the data in a database – How to sort and update database data – To create an application that displays database data in list boxes, text boxes, labels, and combo boxes Chapter 10 – Slide 2

Section 10.1 DATABASE MANAGEMENT SYSTEMS Visual Basic applications use database management systems to make large amounts of data available to programs.

Copyright © 2011 Pearson Addison-Wesley Layered Approach to Using a DBMS Applications that work with a DBMS use a layered approach – VB application is topmost layer – VB sends instructions to next layer, the DBMS – DBMS works directly with data Programmer need not understand the physical structure of the data – Just need to know how to interact with the database Chapter 10 – Slide 4

Copyright © 2011 Pearson Addison-Wesley Visual Basic Supports Many DBMS’s Visual Basic can interact with many DBMS’s – Microsoft SQL Server – Oracle – DB2 – MySQL Chapter 10 – Slide 5

Section 10.3 DATAGRIDVIEW CONTROL The DataGridView control allows you to display a database table in a grid. The grid can be used at runtime to sort and edit the contents of a table.

Copyright © 2011 Pearson Addison-Wesley Connecting to a Database Visual Basic uses a technique called Data binding to link tables to controls on forms We will use these data-related components: – A Data source is usually a database Can include text files, Excel spreadsheets, XML data, and Web services – A Binding source connects data bound controls to a dataset – A Table adapter pulls data from the database and passes it to your program Uses Structured Query Language (SQL) is used to select data, add new rows, delete rows, and modify existing rows – A Dataset is an in-memory copy of data pulled from database tables Chapter 10 – Slide 7

Copyright © 2011 Pearson Addison-Wesley Connecting to a Database The flow of data from database to application – Data travels from data source to application – Application can view/change dataset contents – Changes to dataset can be written back to the data source Chapter 10 – Slide 8

Section 10.4 DATA-BOUND CONTROLS Some controls can be bound to a dataset. A data-bound control can be used to display and edit the contents of a particular row and column.

Copyright © 2011 Pearson Addison-Wesley Advantages of Data-Bound Controls Can bind fields in a data source to controls: – Text boxes – Labels – List boxes Contents of data-bound controls change automatically when moving from row to row Data-bound controls also allow the contents of a database field to be changed Chapter 10 – Slide 10

Copyright © 2011 Pearson Addison-Wesley Adding a New Data Source Open the Data Sources window and click the Add New Data Source link Follow the steps in the Data Source Configuration Wizard to create a connection to the database Chapter 10 – Slide 11

Copyright © 2011 Pearson Addison-Wesley Deleting a Data Source A data source named Employees for example would be defined by a file named Employees.xsd To delete this data source: – Select Employees.xsd file in Solution Explorer – Press Delete on the keyboard Chapter 10 – Slide 12

Copyright © 2011 Pearson Addison-Wesley Binding the Data Source to a DataGridView Control Drag and drop an existing dataset from the Data Sources window to an open area on the form – For example: Chapter 10 – Slide 13

Copyright © 2011 Pearson Addison-Wesley Binding the Data Source to a DataGridView Control At the same time Visual Studio builds a DataGridView on the form, it adds a number of important objects to the form’s component tray: – The BindingNavigator creates a ToolStrip at the top of the form – The DataSet is an in-memory copy of the table – The BindingSource connects the DataGridView to the DataSet – The TableAdapter pulls data from the database into the DataSet – The AdapterManager is a tool for saving data in related tables Chapter 10 – Slide 14

Copyright © 2011 Pearson Addison-Wesley Binding Individual Fields to Controls Use the dataset in the Data Sources window – Select Details from the table drop-down list – Drag table to an open area of a form – Creates a separate control for each field – Can also drag columns individually Text and numeric fields added as text boxes Yes/No fields added as checkboxes DateTime fields use DateTimePicker controls May wish to change some control properties Chapter 10 – Slide 15

Copyright © 2011 Pearson Addison-Wesley Adding Rows to a Database Table A TableAdapter provides an easy way to add a row to a database table To find the TableAdapter you must open a data set’s Schema Definition A schema definition file (.xsd) was automatically created in Tutorial 10-5 for the Members table Dataset – Displays the names and data types of fields in the table To edit the schema definition file: – Double-click its name in the Solution Explorer window – An editor window will open A TableAdapter object was automatically created for the Members DataTable Each DataTable has a TableAdapter associated with it Chapter 10 – Slide 16

Copyright © 2011 Pearson Addison-Wesley Adding Rows to a Database Table A TableAdapter object has an Insert method – Used to add a new row to the database table – Each column is an argument of the method – Just provide the values for each argument – For example: Chapter 10 – Slide 17 MembersTableAdapter.Insert(10, "Hasegawa", "Adrian", " ",#5/15/2010#)

Copyright © 2011 Pearson Addison-Wesley Identity Columns Some database tables have an identity column – Assigned a unique number by the database – Occurs automatically for identity columns – No need to manually supply a value for this column Payments table uses an identity column – Omit ID column value – Only supply Member_Id, Payment_Date, and Amount Chapter 10 – Slide 18 PaymentsTableAdapter.Insert(5, #5/15/2010#, 50D)