Database Applications

Slides:



Advertisements
Similar presentations
Data Base. Objective Become familiar with database terminology. Create a project to display data for a single database table. Use a DataGrid control.
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)
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 10 Accessing Database Files Programming In Visual Basic.NET.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
VB.NET Database Access ISYS 812. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
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.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Tutorial 121 Creating a New Web Forms Page You will find that creating Web Forms is similar to creating traditional Windows applications in Visual Basic.
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.
CHAPTER EIGHT Accessing Data Processing Databases.
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.
CHAPTER EIGHT Accessing Data Processing Databases.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Using Adapter Wizard ISYS 512. Data Adapter Wizard – 2 nd Level of Using ADO.Net Configure Data Adapter and generating a dataset: –From the Data tab of.
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.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
Microsoft Excel 2003 Illustrated Complete Data with Other Programs Exchanging.
BlackBerry Applications using Microsoft Visual Studio and Database Handling.
1 11 Exploring Microsoft Office Access 2007 Chapter 6 Data Protection.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 25 I’m Suffering from Information Overload.
Chapter 24 I’m Suffering from Information Overload (Access Databases) Clearly Visual Basic: Programming with Visual Basic nd Edition.
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.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
COMPUTER PROGRAMMING I 3.01 Apply Controls Associated With Visual Studio Form.
Chapter 9 Working with Databases. Copyright © 2011 Pearson Addison-Wesley Introduction In this chapter you will learn: – Basic database concepts – How.
Creating SQL Database file And Displaying a Database Table in a DataGridView.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
ASP.NET Programming with C# and SQL Server First Edition
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Visual Basic 2010 How to Program
Working with Data Blocks and Frames
Chapter 2: The Visual Studio .NET Development Environment
VB 2010 Pertemuan 10.
Basic Database Concepts
© 2013, Mike Murach & Associates, Inc.
Developing Forms and Subforms.
3.01 Apply Controls Associated With Visual Studio Form
3.01 Apply Controls Associated With Visual Studio Form
ADO.NET Accessing Databases in VS.NET
Microsoft Access 2003 Illustrated Complete
Using Access and the Web
Microsoft Office Illustrated
Brief description on how to navigate within this presentation (ppt)
Working with Databases
CIS16 Application Programming with Visual Basic
Chapter 10 ADO.
Chapter 10 Accessing Database Files
Unit J: Creating a Database
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Database Applications

Visual Basic and Database Files VB projects can display and update the data from database files. VB .NET uses ADO.NET for database access. An advantage of ADO.Net is that information is stored and transferred in Extensible Markup Language (XML). ADO.NET allows the access to database data in many formats including: OleDb, SQLClient for SQL Server (Microsoft’s proprietary DBMS), ODBC, and Oracle. Data from sources such as Access, Oracle, Sybase, or DB2 can be obtained when using OleDb.

Database Terminology Databases Tables—can be viewed like a spreadsheet Records (rows) — data for one item, person, transaction Fields (columns) — store a different element of data Key field (unique to each record) Relational database Multiple tables Relationships between the tables To use database files, the standard terminology of relational databases needs to be understood. A database file (with an .mdf or .mdb extension) can hold multiple tables. Most tables use a key field (or combination of fields) to identify each record.

Database Table Example Any time a database table is open, one record is considered the current record. As you move from one record to the next, the current record changes.

HTML Example <html> <head> <title>Hello World!</title> </head> <body> <h1>Hello world!</h1> <p>This is an HTML document</p> </body> </html>

XML Example <notes> <note> <to>Students</to> <from>Instructor</from> <heading>Reminder</heading> <body>Don't forget the exam next week!</body> </note> <note></note> </notes>

XML Data (1 of 2) Industry-standard format for storing and transferring data The XML needed for accessing databases will be automatically generated in Visual Basic. Data stored in XML is text, identified by tags — similar to HTML tags that can be edited by any text editor program. Tags in XML are not predefined as they are in HTML. Tags can identify fields by name. *Can find specifications at http://www.w3.org/XML, World Wide Web Consortium (W3C)

XML Data (2 of 2) In addition to an XML data file, there is normally an XML schema file. Schema describes the fields, data types, and any constraints, such as required fields. ADO.NET validates the data against the schema and checks for constraint violations. Schema is defined with XML tags and can be viewed/edited in a text editor. ADO.NET can treat the XML data as objects, allowing the IntelliSense feature of the VS.NET environment to provide information to the programmer. Data handling in XML and ADO.NET executes faster than in earlier forms of ADO.

Using ADO.NET and Visual Basic Can display data from a database on Windows Form Web Form Add controls to form and bind data to them. Label, TextBox Special controls designed just for data such as DataGrid, DataList Remember, that controls for a Windows application are different from controls for a Web application and have different properties and events.

The DataGrid View Control The DataGridView control is bound to a table in a dataset. The data fields display automatically in the cells of the grid. You must use several classes and objects to set up data access in Visual Basic.

Data Access in Visual Studio Allows an easy way to create data-bound controls on a form Can drag tables and fields from the window onto a form to automatically create controls that are bound to the data Data can be displayed in grids or individual fields, referred to as details. Can drag a field from the Data Sources window and drop it on an existing control — causes data binding to be set up automatically. An .xsd file and the schema is added to the Server Explorer window; Binding Source, Table Adapter, and Data Set objects are added to the form’s component tray. To set up data access in VB, several classes and objects are used.

Overview of Database Objects Binding Source Establishes a link to the actual data; a specific file and/or server Table Adapter Handles retrieving and updating the data Generates SQL statements that are used to access or update data Dataset Contains actual data — may come from multiple connections and/or multiple data adapters You can add new BindingSource objects using the Data Sources window or the Data menu. No matter where the actual data (the source) for the binding source are, the table adapter transfers data from the source to the dataset (fills) or transfers data from the dataset to the source (updates) all via XML. A dataset is a temporary set of data stored in the memory of the computer. Any controls that you have bound to the dataset will automatically fill with data.

Steps to Display Data in Bound Controls on a Form To display database data in bound controls on a form, a binding source, a table adapter, and a dataset are needed.

Binding Sources Object establishes a link from a specific file or database to the program. Use a wizard to automatically create Binding Source objects –OR— Add new Binding Source objects using the Data Sources window or the Data menu.

Table Adapters Does all the work of passing data back and forth between a data source (the binding source) and a program (the dataset) Data does not have to be from a database. Data can be text file, object, or an array. Transfers data to and from via XML

Datasets Temporary set of data stored in memory In ADO.NET datasets are disconnected; the copy of data kept in memory does not keep an active connection to the data source. Dataset may contain multiple tables and relationships. Any controls bound to the dataset will automatically fill with data. This technique is a big improvement over the recordsets in earlier versions of ADO, which maintain open connections to the data source.

Grid with Pre-Defined AutoFormat Predefined formats can be applied from the AutoFormat item on the smart tag.

The Database Schema File When a new data source is added to a project, a file .xsd is added to the Solution Explorer — the XML schema definition. XML file contains the description and properties of the data. The schema shows the names of the table(s) and fields, the primary keys for each table, and the relationships among the tables. The TableAdapter for the table, which handles different methods for the table, appears at the bottom of the schema.

.XSD (Schema) File The .xsd file holds the schema of the database, where table elements, relationships, and keys can be viewed and modified.

Binding Individual Data Fields Table fields from the dataset can be bound to many types of controls such as labels, text boxes, combo boxes, and check boxes. Controls that are connected to fields are bound controls or data-bound controls. Easiest way to create bound controls is to use the automatic binding feature of the Data Source window. Creates individual text box controls for each field of data and navigation control allowing the user to more from one record to another *The next slide displays a form with data0bound text boxes.

Data-Bound Text Boxes — Example Each text box or check box is bound to one field from the table. As the user clicks the navigation buttons, all controls change to display the data for the next record.

The Data Sources Window This window is used to add a new data source by using the Data Source Configuration Wizard. Click the table name to make a drop- down list available to view Details. The table’s icon changes to match the view.

Selecting Records from a List Allows user to select records to display from a list Fill a ListBox or ComboBox with values from the database –OR— Display the information in a drop-down list and allow the user to make a selection; the corresponding data elements fill remaining fields. The control type can be selected for a bound control in the Data Sources window. The choices are TextBox, ComboBox, Label, LinkLabel, and ListBox.

Selecting Fields from the Table Select individual fields when creating the new data source –OR– after creating the data source. When creating the data source, choose the Add New Data Source option and follow the Configuration Wizard; expand the Tables node and place a check mark on the desired fields. To modify after creating, select the dataset and use the Configuration Wizard and make the field selections from the Wizard. Choose Database Objects, expand the Tables node, and place a check mark on the fields needed. *The next slide displays the Data Source Configuration Wizard.

Data Source Configuration Wizard Select only the fields that are to be included in the Data Source Configuration Wizard.

Choosing the Control Type for Fields Dragging a Details view to a form displays text boxes for the default text fields. Click a field name and choose a control type in the Data Sources window. You can choose the control type for all controls and then drag the table to the form to create the Details view.