Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.

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.
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.
Introduction to Database Processing with ADO.NET.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
VB.NET Database Tools ISYS Net Applications OLE DB Provider OLE DB Data Source OLE DB Provider ODBC Data Source SQL Server Data Source SQL Server.Net.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
Introduction to Data Adapter. A Simplified View of ADO.Net Objects Ado.Net Data Provider Connection Adapter Command Reader Dataset Data Consumer WinForm.
Coding ADO.Net DataSet Objects. DataSet Object A DataSet object can hold several tables and relationships between tables. A DataSet is a set of disconnedted.
Coding ADO.NET Objects: Connection, Command, DataReader.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
VB.NET Database Access ISYS 812. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
VB.NET Database Tools ISYS 573. 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:
Coding ADO.NET Objects: Connection, Command, DataReader.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS546.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
Introduction to ADO.Net and Visual Studio Database Tools
Access Tutorial 10 Automating Tasks with Macros
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Some Basic Database Terminology
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
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.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
1 Lesson 6 — Database Programming Microsoft Visual Basic.NET, Introduction to Programming.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Navigating database with windows forms.. Tiered applications  Provide a means to develop many presentations of the same app  Makes changes to the back.
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Twelve Access Databases and LINQ.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Needs for Accessing Database To make your web site more dynamic and maintainable, you can display information on your web pages that are retrieved from.
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.
Key Applications Module Lesson 21 — Access Essentials
Working with GridView Control: Adding Columns. Adding Buttons to a Bound GridView: 1. Drag the WebProduct table from Data connection to a page 2. Demo.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
Windows Forms Navigating database with windows forms.
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.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
ADO.NET Objects – Data Providers Dr. Ron Eaglin. Requirements Visual Studio 2005 Microsoft SQL Server 2000 or 2005 –Adventure Works Database Installed.
Chapter Thirteen Working with Access Databases and LINQ Programming with Microsoft Visual Basic th Edition.
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.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
HNDIT Rapid Application Development
Coding ADO.NET Objects: Connection, Command, DataReader.
SQL Server Quick Guide. MS SQL Server Express It is installed with the Visual Studio. SQL Server database file extension: mdf Default database folder:
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
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.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Coding ADO.NET Objects: Connection, Command, DataReader
Visual Basic 2010 How to Program
VB.NET Using Database.
Brief description on how to navigate within this presentation (ppt)
CIS16 Application Programming with Visual Basic
Chapter 10 ADO.
Database Applications
Coding ADO.NET Objects: Connection, Command, DataReader
Chapter 10 Accessing Database Files
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512

Client/Server Structure a. Presentation – user interface Menus, forms, reports, etc b. Processing logic Business rules c. Database Client Database Server SQL queries Results

Database Processing Querying database Updating database: –Insertion, deletion, modification

Steps to Retrieve Data Establishes a connection to the database. Executes commands against the database. Store data results.

A Simplified View of ADO.Net Objects Ado.Net Data Provider Connection Adapter Command Reader Dataset Data Consumer WinForm WebForm

ADO.NET Objects Connection Object: Represent a connection to the database. Command Object: The command object allows us to execute a SQL statement or a stored procedure. DataReader: It is a read-only and forward-only pointer into a table to retrieve records. DataSet Object: A DataSet object can hold several tables and relationships between tables. DataAdapter: This the object used to pass data between the database and the dataset.

Data Providers ODBC Provider –Open Database Connectivity A driver manager Used for relational databases OLE DB Provider –OLE DB interfaces provide applications with uniform access to data stored in diverse information sources, or data stores. –Access SQL Server Provider Oracle Provider –Microsoft’s.NET data provider for Oracle –Connecting to Oracle, the Server name is: XE

Using ODBC Windows XP: Control Panel /Administrative Tools/DataSource(ODBC) Three types of data source names –User DSN: usable only by you and only on the machine currently using. –System DSN: Any one using the machine can use. –File DSN: Can be copied and used by other computers with the same driver installed. Demo: –Excel: Data/Import –Access: File/Get External Data/Import, then select ODBC data source

Connecting to Database Adding connection: –Tools/Connect to database Data Source –ODBC –OLD DB (Access) –SQL Server –Oracle, etc. Server Explorer –Data connections: Right click data connection Add Connection –Tables, Views Create new SQL Server Database

Adding Data Source Data/Add New Data Source –Database: Using the connections –Service –Object LINQ To SQL Server

Working with SQL Server Starting SQL Server: –Control Panel/Administrative Tools/Services/SQLServer SQL Server database file extension: mdf Default database folder: testSQL08.mdf –C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\testSQL08.mdf

Creating SQL Server Database From Server Explorer, right click data connection and choose: Create new SQL Server Database Server name: –LocalServerName\SQLExpress Add new table: Right click Tables and choose Add New Table Add rows: Right click the table name and choose Show table data. Note: After creating the database, you may create an ODBC DSN to connect to it.

How to create ADO.Net objects? Automatically generated when creating data bound form. –Form wizard Using Data Adapter Wizard Using code: –Example: –dim strConn as string ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source = c:\sales2k.mdb" –dim objConn as new OledbConnection(strConn) –objConn.open()

Data Binding Connect a control or property to one or more data elements. Simple binding: Use simple binding to display a field value in controls that show Data Bindings in the property window, such as text box or label. Complex binding: Use complex binding to bind more than one field to controls such as DataGrid and list box. Use the control’s Data Source and Data Member to bind the data.

Creating Data Bound Form Creating a form with ADO.Net objects and data- bound controls to display and update information in a dataset. Demo: –Add data source: Data/Add New Data Source Data/Show Data Source –Click the dropdown list next to the table’s name: Datagrid view Details –Drag the table to form.

Items Added to the Form Connection Table Adapter: click smart tag –Add query –Preview data Dataset: –Edit in dataset designer Binding Source –Add query: Add a new tool strip. –Preview data Binding navigator Code view: Form load event

Generated Code Private Sub CUSTOMERBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CUSTOMERBindingNavigatorSaveItem.Click Me.Validate() Me.CUSTOMERBindingSource.EndEdit() Me.CUSTOMERTableAdapter.Update(Me.SalesDBDataSet.CUSTOMER) End Sub Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'SalesDBDataSet.CUSTOMER' table. You can move, or remove it, as needed. Me.CUSTOMERTableAdapter.Fill(Me.SalesDBDataSet.CUSTOMER) End Sub

Other Data Form Demos DataGrid View Add /Modify/Delete records. Read only form: –Delete AddNew, Delete, Save buttons from navigator bar.

Hierarchical Forms Parent table/Child table –Add parent table and child table to Data Source –Drag the parent table and the child table to the form. Parent table uses detail view and child table uses dataGrid view –RightClick Dataset object to choose Edit in Dataset Designer –With the designer, right click the parent table and choose Add/Relation –Change dataGrid’s DataSource property to the relation.

Detail Form with Bound ListBox Example: Customer table form with CID listbox and displays selected customer information in textboxes. –Choose detail view for the customer table. –Click the dropdown list next to the CID field and click ListBox –Drag the Customer table to the form. –Bind the CID field to the BindingSource: Activate the Property window and click the listbox Set the DataSOurce property to BindingSource Set the Display Member property to CID

Creating A Database Application Without Programming Creating a database application to display information and update database. A main form with buttons to open data forms: –DisplayInfo –Enter New –Modify –Exit