CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.

Slides:



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

ADO vs ADO.NET ADOADO.NET Client/server coupledDisconnected collection of data from data server Uses RECORDSET object (contains one table) Uses DATASET.
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.
VB.NET Database Access ISYS546. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
ASP.NET and ADO.NET. ASP.NET Server Controls Intrinsic Controls: These controls correspond to their HTML counterparts. –Ex. Textbox, listbox, button,
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.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
VB.NET Database Tools ISYS 573. Microsoft Universal Data Access ODBC: Open Database Connectivity –A driver manager –Used for relational databases OLE.
Coding ADO.NET Objects: Connection, Command, DataReader.
CIS 451: ASP Recordsets Dr. Ralph D. Westfall May, 2002.
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.
Stored Procedures Dr. Ralph D. Westfall May, 2009.
Chapter 10 - VB.Net by Schneider1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Relational Databases and SQL.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
CIS 451: ASP.NET Debugging and Server-Side Includes Dr. Ralph D. Westfall February, 2009.
Chapter 9 Using the SqlDataSource Control. References aspx.
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.
Chapter 61 Managing Data Sources Introduction to ASP.NET By Kathleen Kalata.
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 A2 Teacher Up skilling LECTURE 3. What’s to come today? ADO.NET What is ADO.NET? ADO.NET Objects SqlConnection SqlCommand SqlDataReader DataSet.
Overview of Data Access MacDonald Ch. 15 MIS 324 Professor Sandvig.
Developing Web Applications Using Microsoft ® Visual Studio ® 2008.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
CIS 375—Web App Dev II ASP.NET 10 Database 2. 2 Introduction to Server-Side Data Server-side data access is unique in that Web pages are basically ___________.
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.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with Disconnected Data The DataSet and SqlDataAdapter ADO.NET - Lesson.
CIS 451: USING ASP.NET TO CREATE XML Dr. Ralph D. Westfall February, 2009.
CIS 338: Using Queries in Access as a RecordSource Dr. Ralph D. Westfall May, 2011.
ASP.NET - accessing the database - datareader vs dataset - datagrid vs datalist - brief look at web matrix.
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.
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.
Object Oriented Software Development 10. Persistent Storage.
Presented by Joseph J. Sarna Jr. JJS Systems, LLC
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.
 It is the primary data access model for.Net applications  Next version of ADO  Can be divided into two parts ◦ Providers ◦ DataSets  Resides in System.Data.
JDS – VB.NET Skill Session Fall 2004 Presented by YUHAO LIN.
CIS 375—Web App Dev II ASP.NET 9 Database. 2 ADO.NET What is ADO.NET? ADO.NET is a part of the.NET Framework ADO.NET consists of a set of classes used.
DEV383 The ADO.NET DataSet and You Jackie Goldstein General Manager Renaissance Computer Systems
ASP.NET Binding and an Introduction to Database Queries Please use speaker notes for additional information!
ASP.NET - insert - delete -update DataTables (disconnected datasets) Shopping Basket.
HNDIT Rapid Application Development
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
ADO.NET in VB.NET 2005 ITE 370 4/26/2017.
1 Database Programming with ADO.NET Kashef Mughal.
Active Data Objects Using.Net ADO.Net Farooq Ahmed Amna Umber Summayya Shehzad.
Introduction to ASP.NET, Second Edition2 Chapter Objectives.
ASP.NET Programming with C# and SQL Server First Edition
Introduction to Database Processing with ADO.NET
Coding ADO.NET Objects: Connection, Command, DataReader
Introduction to Database Processing with ADO.NET
Unit 9.1 Learning Objectives Data Access in Code
ADO.NET Framework.
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
Active Data Objects Binding ASP.NET Controls to Data
ADO.NET Accessing Databases in VS.NET
ASP.NET and ADO.NET.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Chapter 10 ADO.
Coding ADO.NET Objects: Connection, Command, DataReader
Active Data Objects Binding ASP.NET Controls to Data
M S COLLEGE OF ART’S, COMM., SCI. & BMS Advance Web Programming
Presentation transcript:

CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009

ASP.NET Database Capabilities ASP.NET objects offer multiple ways to access data in databases has a number of objects, with numerous properties, that can be used to open and get data from different types of data sources ASP.NET uses SQL in different ways with some of these objects

ASP.NET Database Objects can use the following objects don't always have to create all of them some are created when create others Connection: to database Command: SQL code or other command DataAdapter: bridge between the database and the application DataSet: holds data DataView: more flexible than DataSet

Set Up ASP.NET for a Database need the following lines at the top of an.aspx file to make database capabilities accessible or use Imports statement in aspx.vb file 'Microsoft Access and/or SQL Server 'Sub Page_Load … … … … … … … … … End Sub

Connection Object creating in code (prodtestbuild.aspx)prodtestbuild.aspx semicolons in the "connection string" separate parameters (driver; path; etc.) Dim strCon as String strCon = "Provider=Microsoft.Jet.OLEDB.4.0;" strCon += "Data Source=" & _ "\example.mdb"example.mdb assumes database is in project's \bin subdirectory

Connection Object - 2 opening Dim objCon = New _ OledbConnection(strCon) 'previous pg. objCon.Open() closing objCon.Close() 'to free memory after database is used

Command Object has following properties to use with it Connection – to database or etc. CommandType can be Text (default): SQL string, procedure name … TableDirect: name of a table StoredProcedure: name inside a database CommandText SQL string, SQL stored procedure name, etc.

Creating a Command Object 'for a Microsoft Access database Dim strSQL as String Dim objCommand as OleDbCommand Dim strCity as String objCommand = New OleDbCommand(strSQL, _ objCon) 'slide 6 strSQL = "select * from Customer " 'space 'for a SQLServer database, would use SqlCommand( … instead of OleDbCommand( …

Variables in SQL for Command can limit output by using variables as conditions strCity = "Colusa" " where City <> '" & strCity & "'; " 'note space before where 'also single quotes inside quotes 'single quotes identify string data 'in SQL

DataReader Object high speed, read only, forward only connection between database and application Dim objDataRead as OleDbDataReader objCon.Open() objDataRead = objCommand.ExecuteReader()

Getting Data from DataReader reads forward one row at a time each read also returns a Boolean value row fields are identified by field names Dim strCity as String 'objDataRead below is from slide 10 Do While objDataRead.Read() ' = True strCity = ObjDataRead("City") Response.Write(strCity & " ") Loop 'until objDataRead.Read() = False

DataAdapter Object transfers data from database to an application into a DataSet object that holds the data in the application Dim objDA as OleDbDataAdapter 'strSQL = "select * from Product " 'if not above, Connection object code here objDA = New OleDbDataAdapter(strSQL, objCon)

DataSet Object holds data retrieved from database disconnected: changes do not go directly back into database inflexible e.g., can't sort contents can be bound to a control e.g., DataGrid Dim objDS as DataSet objDS = New DataSet()

DataSet Object - 2 objDA.SelectCommand = new _ OleDbCommand(strSQL, objCon) objDA.Fill(objDS, "Product")

DataTable & DataRow Objects Dim intProdCount as Integer Dim objTable as DataTable Dim objRow as DataRow objTable = objDS.Tables("Product") objRow = objTable.Rows(0) 'or variable intProdCount = objRow("InStock") 'add.ToString on end of line if errors

CommandBuilder Object sets up SQL commands so that they run on Microsoft Access or on other sources avoids problems when trying to use SQL commands directly against specific data sources Dim objBuild as OleDbCommandBuilder objBuild = New OleDbCommandBuilder(objDA)

CommandBuilder Object - 2 updating (select, insert, delete similar) objDA.UpdateCommand = _ objBuild.GetUpdateCommand() intProdSold = 1 intProdCount = intProdCount - intProdSold objRow("Instock") = intProdCount objDA.Update(objDS, "Product") 'code

DataView Object can be bound to a control in the output Dim objDV as DataView objDV = New _ DataView(objDS.Tables("Product"))

Binding to Database Data can hook GridView data to a DataView to show output in the browser GridView replaced DatGrid in VS.NET 2005 gvProd.DataSource = objDV 'in a Sub gvProd.DataBind()

Exercise: Use GridView create some code in Visual Studio and use a DataGrid to output data from a database table onto a web page