Chapter 9 Using the SqlDataSource Control. References 2206-1.aspx.

Slides:



Advertisements
Similar presentations
17. Data Access ADO.Net Architecture New Features of ADO.NET
Advertisements

User Controls, Master Pages, GridView. Content User Controls Styles, Themes, Master Pages Working with Data GridView Muzaffer DOĞAN - Anadolu University2.
Chapter 10 ADO. What is ADO? ADO is a Microsoft technology ADO stands for ActiveX Data Objects ADO is a programming interface to access data in a database.
Introduction to Database Processing with ADO.NET.
Performed by:Gidi Getter Svetlana Klinovsky Supervised by:Viktor Kulikov 08/03/2009.
ASP.NET Programming with C# and SQL Server First Edition
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 12 Database Connectivity with ASP.NET JavaScript, Third Edition.
Chapter 7 Managing Data Sources. ASP.NET 2.0, Third Edition2.
CONFIGURING WINDOWS SERVER MIS 424 Professor Sandvig.
Philip Wolfe Senior Consultant Sogeti Session 3 - Leveraging Data in ASP.NET 2.0 (Level 200)
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
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.
Chapter 10 Managing Data with ASP.NET. ASP.NET 2.0, Third Edition2.
CSCI 6962: Server-side Design and Programming Secure Web Programming.
ASP.NET Part 4 Instructor: Charles Moen CSCI/CINF 4230.
Chapter 61 Managing Data Sources Introduction to ASP.NET By Kathleen Kalata.
1 PHP and MySQL. 2 Topics  Querying Data with PHP  User-Driven Querying  Writing Data with PHP and MySQL PHP and MySQL.
Chapter 81 Building Data-Driven Web Applications Introduction to ASP.NET By Kathleen Kalata.
Chapter 71 Building Data-Driven ASP.NET Applications Introduction to ASP.NET By Kathleen Kalata.
ADO.NET Tools and Wizards. Slide 2 Data Sources Window (Introduction) Use the Data Sources window to Establish a connection Create bound control instances.
Overview of Data Access MacDonald Ch. 15 MIS 324 Professor Sandvig.
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
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.
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.
Malek Kemmou Technology Architect, Application Platform Microsoft Middle East and Africa Using Visual Studio 2005 to Build Data- Driven.
Ventsislav Popov Crossroad Ltd.. 1. ASP.NET Data Source Controls  SqlDataSource  EntityDataSource  ObjectDataSource 2. Entity Data Model and ADO.NET.
1 Introduction to ADO.NET Microsoft ADO.NET 2.0 Step by Step Rebecca M Riordan Microsoft Press, 2006.
DataSource controls in.NET How to access databases.
Delivering Excellence in Software Engineering ® EPAM Systems. All rights reserved. Data Binding in ASP.NET.
Objectives In this lesson, you will learn to: *Identify the need for ADO.NET *Identify the features of ADO.NET *Identify the components of the ADO.NET.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
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.
ASP.NET Rina Zviel-Girshin Lecture 5
Session 8: ADO.NET. Overview Overview of ADO.NET What is ADO.NET? Using Namespaces The ADO.NET Object Model What is a DataSet? Accessing Data with ADO.NET.
Chapter 8 Working With Databases in ASP.NET. Listing 8.1 – ShowListControls Uses The SqlDataSource control for estabishing database connectivity and.
ADO.NET Data Access. Page  2 SQL  When we interact with the datasource through ADO.NET we use the SQL language to retrieve,modify,update information.
ASP.NET OPTIMIZATION. Why Optimize? $$$ Whether you build applications for customers or not, enhanced applications save money.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Mauricio Featherman, Ph.D. Washington St. University
Ventsislav Popov Crossroad Ltd.. 1. ASP.NET Data Source Controls  SqlDataSource  EntityDataSource  ObjectDataSource 2. Entity Data Model and ADO.NET.
DEV383 The ADO.NET DataSet and You Jackie Goldstein General Manager Renaissance Computer Systems
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
HNDIT Rapid Application Development
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
1 CS 3870/CS 5870: Note07 Prog 4. Master Pages Creating a master page based on another master page MainMasterPage –For all Progs and Tests Prog4MasterPage.
Session 8: Data Management (with Stored Procedures)
Module 2: Using ADO.NET to Access Data. Overview ADO.NET Architecture Creating an Application That Uses ADO.NET to Access Data Changing Database Records.
ASP.net Course From Intermediate to Advance level By Arsalan Ahmed 3 Months Course Cell :
Data Access. ADO.NET ADO.NET is the primary library for building database solutions within the.NET Framework. ADO.NET does not replace ADO. ADO and OLEDB.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
DAT 390 Advanced ADO.NET Programming Techniques Jackie Goldstein Renaissance Computer Systems
ASP.NET Programming with C# and SQL Server First Edition
Introduction to Database Processing with ADO.NET
Introduction to Database Processing with ADO.NET
Unit 9.1 Learning Objectives Data Access in Code
ADO.NET Framework.
PROG Advanced Web Apps 5/23/2018 Notes on ADO.NET (1) Wendi Jollymore, ACES.
Programming the Web Using ASP.Net
Active Data Objects Binding ASP.NET Controls to Data
VB.NET Using Database.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 10 ADO.
Active server pages (ASP.NET)
PROG Advanced Web Apps 4/13/2019 Programming Data Pages Wendi Jollymore, ACES.
Active Data Objects Binding ASP.NET Controls to Data
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Presentation transcript:

Chapter 9 Using the SqlDataSource Control

References aspx

The SqlDataSpource Control The SqlDataSource control enables you to quickly and easily represent a SQL database in a web page. The SqlDataSource control is built on top of ADO.NET. Under the covers, theSqlDataSource uses ADO.NET objects such as the DataSet, DataReader, and Command objects. Because the SqlDataSource control is a control, it enables you to use these ADO.NET objects declaratively, rather than programmatically.

Connecting to Microsoft SQL Server Be default, the SqlDataSource control is configured to connect to Microsoft SQL Server. The default provider used by the SqlDataSource control is the ADO.NET provider to Microsoft SQL Server.

SqlConnectionBuilder The.NET Framework includes a utility class names the SqlConnectionBuilder class that you can use when working with SQL connection strings. Thes class automatically converts any connection string into a canonical representation. It also exposes properties for extracting and modifying individual connection string parameters such as the Password parameters.

SqlConnectionStringBuilder

Storing Connection Strings in the Web Configuration File Storing connection string in your pages is a bad idea for three reasons Not a good practice from the perspective of security Adding a connection string to every page makes it difficult to manage a website. Storing a connection string in a page can potentially hurt the performance of your application

Executing Database Commands Executing Inline SQL Statements The SqlDataSource control supports SelectCommand InsertCommand UpdateCommand DeleteCommand

SelectCommand <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString=" " SelectCommand="SELECT [customer_id], [lname], [fname] FROM [customer]">

Executing Stored Procedures The SqlDataSource control can represent SQL stored procedures just as easily as it can represent inline SQL commands. You can indicate that a command represents a stored procedure by assigning the value StoredProcedure to SelectCommandType InsertCommandType UpdateCommandType DeleteCommandType

Executing Stored Procedure <asp:SqlDataSource ID="SqlDataSource1" runat="server "ConnectionString=" " SelectCommand="sp_getCustomer" SelectCommandType="StoredProcedure">

Data returned from the underlying database by the SqlDataSource control DataReaders - a DataReader offers forward- only, read-only access to a database, and requires an active connection. More efficient than a DataSets/DataTables/DataViews. DataSet/DataTable/DataView - a DataTable offers a random access, editable representation of a query. A DataSet is a collection of DataTables. DataViews can be used to retrieve a filtered or sorted subset of records in a DataTable.

Handling SQL Command Execution Errors You can handle errors thrown by the SqlDataSource control by handling any or all of the following Deleted Inserted Selected Updated Each is passed an EventArgs parameter

Using Parameters with the SqlDataSource Control Parameter-Represents an arbitrary static value ControlParameter-Represents the value of a control or page property CookieParameter-Represents the value of a browser cookie FormParamter-Represents the value of an HTML form field ProfileParameter-Represents the value of a Profile property QueryStringParameter-Represents the value of a query string field SessionParameter-Represents the value of an item stored in Session state

ASP.Net Parameter Object Properties Include ConvertEmptyStringToNull-When true, if a parameter represents an empty string then the empty string is converted to the value Nothing(null) before the associated command is executed

ASP.Net Parameter Object DefaultValue-When a parameter has the value Nothing(null) the DefaultValue is used for the value of the parameter Direction-Indicates the direction of the parameter. Possible value are Input, InputOutput, Output, and ReturnValue

ASP.Net Parameter Object Name-Indicates the name of the parameter. Size-Indicates the data size of the parameter Type-Indicates the.Net Framework type of parameter. You can assign any value from the TypeCode enumeration to this property.