1 Database Programming with ADO.NET Kashef Mughal.

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

Stored procedures and views You can see definitions for stored procedures and views in the demo databases but you can’t change them. For views, expand.
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.
1 Web-Enabled Decision Support Systems Advance Topics in Database Connectivity Prof. Name Position (123) University Name.
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
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.
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.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Pasewark & Pasewark 1 Access Lesson 4 Creating and Modifying Forms Microsoft Office 2007: Introductory.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Access Tutorial 10 Automating Tasks with Macros
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.
Databases and LINQ Visual Basic 2010 How to Program 1.
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.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
ADO.NET A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Creating a Web Site to Gather Data and Conduct Research.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
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.
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.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Neal Stublen Populating a Database  SQLExpress should be installed with Visual Studio  The book provides a.sql file for populating.
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.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Examining.
Create Forms Lesson 5. Objectives Software Orientation The Forms group (below) is located on the Create tab in the Ribbon and can be used to create a.
Database Systems Microsoft Access Practical #3 Queries Nos 215.
Office Management Tools II Ms Saima Gul. Office Management Tools II Ms Saima Gul.
ASP.NET The Clock Project. The ASP.NET Clock Project The ASP.NET Clock Project is the topic of Chapter 23. By completing the clock project, you will learn.
Module 7: Accessing Data by Using ADO.NET
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.
ADO.NET Objects – Data Providers Dr. Ron Eaglin. Requirements Visual Studio 2005 Microsoft SQL Server 2000 or 2005 –Adventure Works Database Installed.
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.
© 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.
HNDIT Rapid Application Development
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.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
CSCI 3327 Visual Basic Chapter 13: Databases and LINQ UTPA – Fall 2011.
VB.NET and Databases. ADO.NET VB.Net allows you many ways to connect to a database. The technology used to interact with a database or data source is.
Creating SQL Database file And Displaying a Database Table in a DataGridView.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
Visual Basic 2010 How to Program
ADO.NET Framework.
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
Objectives Create an action query to create a table
ADO.NET Accessing Databases in VS.NET
VB.NET Using Database.
Database Queries.
Brief description on how to navigate within this presentation (ppt)
CIS16 Application Programming with Visual Basic
Introduction to Database Programs
Chapter 10 ADO.
Database Applications
Chapter 10 Accessing Database Files
Introduction to Database Programs
Tutorial 9 Using Action Queries and Advanced Table Relationships
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

1 Database Programming with ADO.NET Kashef Mughal

2 Last Week  We looked at the following:  OleDbConnection - active connection to the database for an OLEDB provider  DataSet - subset of the database, can be updateable  OleDbDataAdapter - data bridge between the OleDbConnection and the DataSet for an OLEDB provider  OleDbCommand - SQL command that is executed against the database

3 This Week  We are going to work with the following:  SqlConnection - active connection to the SQL Server database - carries the connection info  SqlDataAdapter - data bridge between the SqlConnection and the DataSet for a SQL Server database  SqlCommand - SQL command that is executed against the database which in this case is SQL  Why different objects for SQL Server? These are optimized for retrieving data from SQL Server

4 A few thing about SQL Server  Enterprise database from Microsoft  Comes in versions 7, 2000 and YUKON (not out yet)  Think of SQL Server as Access on steroids  Enterprise Manager is the tool of choice for SQL Server administration  Query Analyzer is the tool of choice for testing queries and SQL code  Go ahead and open Enterprise Manager from Start - Program Files - Microsoft SQL Server - Enterprise Manager

5 Enterprise Manager  Expand SQL Server Group  Expand your Server  Expand Database  Expand Northwind  Expand pubs  Select tables  Right click on Authors table and select Return all rows

6 Query Builder in EM  Click on the Show/Hide Diagram pane - Second Tool Bar button  Click on the Show/Hide Grid pane - Third Tool Bar button  Click on the Show/Hide SQL pane - Fourth Tool Bar button  Does this look familiar ?  You can use this to build your SQL and then paste it in VB.NET

7 Connection String parameters  Server - machine name  Database - e.g. Northwind  uid - username  pwd - password  Integrated Security - set to true if using Windows Authentication

8 Back to VB.NET  sqlCommand represents a SQL command that can be executed against the Database  Last week we used SELECT command  Connection property of sqlCommand represents the connection to the database  CommandText property of sqlCommand is the actual SQL command - Remember that this is a string so you will have to use double quotes  Parameter Collection is used with parameters  ExecuteNonQuery method with execute the SQL

9 sqlDataAdapter  sqlDataAdapter is similar to OleDbDataAdapter in that it is a bridge between db and Data Set  SelectCommand property is used to specify the SQL for sqlDataAdapter  Fill is the method used to populate a Data Set using sqlDataAdapter

10 Data View object  Works with the Data Set object  Difference lies in the fact that Data View can be used for sorting and filtering data  Sort property will sort the data  RowFilter property is used to return only data with a specific criteria - similar to WHERE clause

11 Exercises  Try the following ones  Page 637  Page 641  Take a break when finished

12 The Server Explorer Window  The Server Explorer can help you quickly create data driven applications as well as allow you to create SQL databases.  The Server Explorer has two nodes at the top: Data Connections and Servers.  The Data Connections node lists the databases that you've created a connection to using the data adapter wizard. The Servers node lists the db servers available to you.

13 Server Explorer Screen Shot

14 Advantages of Server Explorer  Database Administration - You can not only view the objects but can create new ones - You may not have access to Enterprise Manager and can use this tool instead  Can create multiple connections from the same window  Monitor events and counters on your machine or other servers  Minimize the code you need to write as shown in the next section

15 Advantages of Server Explorer - Part 2  We will be using pubs database on the SQL Server  Start a new Project in Vb.NEt  Drag the authors table from the Server explorer to the form  Notice it created a connection and sql adapter  Right click on sqldataadapter1 and Preview Data  Right click and select Generate DataSet (New)  Add a Data Grid to the form and set properties  Add the code to the Form Load event

16 DATA FORM WIZARD  The data form wizard allows you to quickly create a data bound form complete with the appropriate ADO.NET objects and bound controls.  To use the wizard add a new item to your project by right clicking on the application name and choosing Add-->Add New Item  This will start the wizard  Pick new data set option, call it myDS - Next  Use existing SQL connection - Next

17 DATA FORM WIZARD - Part 2  Select the employee table - Next  Make sure all the fields are selected - Next  How do you want to display data - Pick single record - Leave all the options check and select Finish  Wow - You are done  Make sure you have this DataForm1 selected as default  Run the bad boy!

18 A few more terms  Data Binding is the term used when you are using bound data control like a data grid  Binding Context object manages all the bindings of the controls on a form  It does this my managing a collection of currencymanager objects  Currency Manager is responsible for keep data consistent between objects and data source

19 Exercises  Try the following ones  Page 647  Page 659  Page 661  Take a break when finished  Remember next week is Final

20 Final  Chapter 8-16 minus Chapter 13  In-class material  Open Book, open notes  100 questions  true/false  multiple choice  a few from the midterm  200 points  2 hours  Grades right now