Introduction to ADO.Net and Visual Studio Database Tools.

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.
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:
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 ISYS 512.
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
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
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 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.
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.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
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.
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.
Module 7: Accessing Data by Using ADO.NET
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.
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.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
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.
Coding ADO.NET Objects: Connection, Command, DataReader.
1 Database Programming with ADO.NET Kashef Mughal.
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.
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.
CS 281 – Fall 2010 Lab 4 Parametric Query and Forms in MS Access.
Creating SQL Database file And Displaying a Database Table in a DataGridView.
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.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
Visual Basic Database Access
Introduction to Database Processing with ADO.NET
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Introduction to Database Processing with ADO.NET
Visual Basic 2010 How to Program
© 2013, Mike Murach & Associates, Inc.
ADO.NET Accessing Databases in VS.NET
VB.NET Using Database.
Brief description on how to navigate within this presentation (ppt)
VISUAL BASIC INTRODUCTION TO DATA CONNECTIVITY.
CIS16 Application Programming with Visual Basic
Chapter 10 ADO.
Database Applications
Chapter 10 Accessing Database Files
Presentation transcript:

Introduction to ADO.Net and Visual Studio Database Tools

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

Steps to Retrieve Data Establishes a connection to the database. Executes query commands against the database. –SQL Select commands Process the returned data.

Steps to Update Data Establishes a connection to the database. Executes update commands against the database. –SQL Insert, Delete, Update commands Receive confirmation of completion.

ADO.Net: Connected and Disconnected Data Processing The ADO.Net environment can be categorized into connected and disconnected environments. –A connected environment requires a constant connection to transfer data between the client application and the data source. –A disconnected environment retrieves data and performs modification without a constant connection to the data source.

ADO.Net Classes

ADO.Net Classes and Data Consumer Ado.Net Connection Adapter Command DataReader 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. –MS Access (accdb) SQL Server Provider Oracle Provider Etc.

Using ODBC Windows 7: Control Panel /Administrative Tools/DataSource(ODBC) Three types of data source names, DSN –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. Note: For 32 bit software, you have to open the ODBC panel from C:\Windows\SysWOW64\odbcad32.exe

Define an ODBC DSN for Access Database Download: SalesDB2011.accdb Open ODBC Window Define a System DSN to SalesDB2011 and name it: MySalesData

SQL Server Express/ SQL Server Express LocalDB SQL Server Express is available free from Microsoft, but it requires more computer resources. SQL Server Express LocalDB is a light- weight version of SQL Server Express that is already installed with VS 2013.

VS Database Tools View/Server Explorer: –For connection to ODBC data sources, OleDB to MS Access, and SQL Server Express View/SQL Server Object Explorer –For connection to SQL Server LocalDB

Connect to Access Database using OLE DB From Server Explorer, right-click Add Connection: –Microsoft Access Database File (OLE DB) –Browse for database –Test Connection Tools/Connect to database

Connect to Access Database using ODBC From Server Explorer: –right-click Add Connection –Click Change –Microsoft Access ODBC Data source –Select DSN from the dropdown list –Test Connection

Working with SQL Server Express LocalDB View/SQL Server Object Explorer Point to SQL Server and Right-click: –Add SQL Server Connect to Server –Serve name: (localdb)\Projects –Connect

Lab: Creating a LocalDB Database Database Name: MyDept Tables: –Department: DID, Dname, Office –Employee EID, Ename, Sex, Salary, HireDate, DID

To Add a New Database Open the LocalDB node Right-click Databases –Add new database Enter database name –Example: MyDept

To Add a New Table: Department Open the Database node: Open the MyDept node Right-click Tables and select: Add New Table Change the table name to Department –CREATE TABLE [dbo].[Department] Define fields Click Update Click Update Database

To Add Records Open the Tables node Right-click the table name (Department) and select View Data

To Modify Table Design Point and right-click the table name: –Select: View/Designer Change the CREATE TABLE command Or Change the design with the designer

Add Employee Table Right-click Tables and select Add Table: –EID, Ename, Sex, Salary, HireDate, DID Add records

Three Ways to Create ADO.Net Objects 1. Automatically generated when creating data bound form. –Form wizard 2. Using Data Adapter Wizard 3. Using code: –Example: –string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\CSharpexamples\\SalesDB2011.accdb"; –OleDbConnection objConn = 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.

Automatically Generating Data Bound Form Creating a form with ADO.Net objects and data- bound controls to display and update information in a dataset. Step 1: Add a new data source: Step 2: Select controls for table fields: –Click the dropdown list next to the table’s name: Datagrid view Details Step 3: Drag the table to form.

Add Data Source Data Source window: –View/Other windows/Data Source Add New Data Source –From Dataset –Select connection –Select tables

Data Bound Form Examples Using the LocalDB database MyDept, show records of the Employee table: –with dataGridView –with detail view

Items Added to the Form Table Adapter: click smart tag –Add query –Preview data Dataset: –Edit in dataset designer Binding Source: It is an object that keeps track of position (the current row) of a data source. –Preview data Code view: –Form load event: Adapter’s Fill command

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

Hierarchical Forms: Department/Employees 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 –Click Dataset object’s smart tag 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 (shown under the parent table’s binding source).

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

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