ASP.NET - insert - delete -update DataTables (disconnected datasets) Shopping Basket.

Slides:



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

Chapter 10 Database Applications Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
1 Web-Enabled Decision Support Systems Advance Topics in Database Connectivity Prof. Name Position (123) University Name.
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.
Chapter 12: ADO.NET and ASP.NET Programming with Microsoft Visual Basic.NET, Second Edition.
Using ADO.NET Chapter Microsoft Visual Basic.NET: Reloaded 1.
ASP.NET Database Connectivity I. 2 © UW Business School, University of Washington 2004 Outline Database Concepts SQL ASP.NET Database Connectivity.
1 Pertemuan 09 Database Matakuliah: D0524 / Algoritma dan Pemrograman Komputer Tahun: 2005 Versi:
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Chapter 8 Binding Data to Web Controls. ASP.NET 2.0, Third Edition2.
9-1 Chapter 9 Working with Databases in VB.NET. 9-2 Learning Objectives Understand how databases are used to store business data and how they differ from.
CSCI 6962: Server-side Design and Programming
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.
CSCI 6962: Server-side Design and Programming JDBC Database Programming.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 512.
10-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Chapter 81 Building Data-Driven Web Applications Introduction to ASP.NET By Kathleen Kalata.
CIS 451: Using ASP.NET Objects with SQL Dr. Ralph D. Westfall February, 2009.
A Simple Introduction. What is ADO.net? First the word ADO stands for ActiveX Data Objects And it is an integral part of.Net Framework of Microsoft hence.
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.
MySQL Databases & PHP Integration Using PHP to write data to, and retrieve data from, a MySQL database.
ASP.NET Event Handlers Database -> Browser ->Shopping Basket Validators.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 Working with Disconnected Data The DataSet and SqlDataAdapter ADO.NET - Lesson.
Oracle Data Integrator Procedures, Advanced Workflows.
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.
CSCI 6962: Server-side Design and Programming Database Manipulation in ASP.
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.
Module 7: Accessing Data by Using ADO.NET
Christopher M. Pascucci.NET Programming: Databases & ADO.NET.
ASP.NET More on searching databases 1ASP.NET, More on searching databases.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
 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.
Mauricio Featherman, Ph.D. Washington St. University
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
CSCI 6962: Server-side Design and Programming JSF DataTables and Shopping Carts.
ADO.NET AND STORED PROCEDURES - Swetha Kulkarni. RDBMS ADO.NET Provider  SqlClient  OracleClient  OleDb  ODBC  SqlServerCE System.Data.SqlClient.
Unbound Form Form not tied directly to any fields in the database Must use SQL to “bind” the fields 1.
HNDIT Rapid Application Development
2314 – Programming Language Concepts Introduction to ADO.NET.
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#.
ADO.NET in VB.NET 2005 ITE 370 4/26/2017.
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.
SQL Query Analyzer. Graphical tool that allows you to:  Create queries and other SQL scripts and execute them against SQL Server databases. (Query window)
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.
Introduction to ADO.Net and Visual Studio Database Tools ISYS 350.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
.NET Data Access and Manipulation
Common SQL keywords. Building and using CASE Tools Data Base with Microsoft SQL-Server and C#
Introduction to Database Processing with ADO.NET
Database Access with SQL
Introduction to Database Processing with ADO.NET
Databases.
ADO.NET Framework.
© 2016, Mike Murach & Associates, Inc.
Programming the Web Using ASP.Net
Lecture 6 VB.Net SQL Server.
Tonga Institute of Higher Education
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Stores data in different tables
Chapter 10 ADO.
These slides are for reference only. They are not "lecture notes"
Introduction to ADO.Net and Visual Studio Database Tools.
Presentation transcript:

ASP.NET - insert - delete -update DataTables (disconnected datasets) Shopping Basket

Insert Using the INSERT SQL statement with data hard-wired into it Using the INSERT SQL statement with placeholder variables to be filled by user input. – Parameters.Add used to fill placeholders

Insert using SQL command Open connection to database as usual, then: Dim dothis As OleDbCommand Dim strInsert As String strInsert = "INSERT INTO Company (CompanyName, City) VALUES ('Blue Bird', 'Leeds')" dothis= New OleDbCommand(strInsert, objConn) dothis.ExecuteNonQuery

Insert using Add method of OleDbCommand Dim dothis As OleDbCommand Dim strInsert As String strInsert= "INSERT INTO Company (CompanyName, City) dothis= New OleDbCommand(strInsert, objConn) txtCompany.Text) txtCity.Text) Dothis.ExecuteNonQuery

Delete SQL DELETE command SQL DELETE with Parameters.Add

Delete using SQL Dim dothis As OleDbCommand Dim strDelete As String strDelete = “DELETE FROM” &;_ “Company WHERE CompanyName = ‘Blue Bird’” dothis= New OleDbCommand(strDelete, objConn) dothis.ExecuteNonQuery

Delete using Add method of OleDbCommand strDelete = “DELETE FROM Company WHERE CompanyName dothis= New OleDbCommand(strDelete, objConn) txtCompanyName.Text) dothis.ExecuteNonQuery

Update Executing an SQL statement with the UPDATE command against the database. SQL UPDATE with Parameters.Add

Update using SQL strUpdate = “UPDATE JobList SET EstimatedSalary = EstimatedSalary * 1.10 WHERE JobTitle = ‘Network Administrators’” dothis= New OleDbCommand(strUpdate, objConn) dothis.ExecuteNonQuery

Update using Add method of OleDbCommand strUpdate = “Update JobList SET EstimatedSalary WHERE JobTitle dothis= New OleDbCommand(strUpdate, objConn) txtEstimatedSalary.Text) txtJobTitle.Text) dothis.ExecuteNonQuery

DataTables Table stored in server memory Disconnected DataSet Used for – Manipulating subsets of data – Shopping basket

Defining a datatable 1 – define columns Dim objDT As System.Data.DataTable objDT = New System.Data.DataTable("Cart") objDT.Columns.Add("Product", GetType(String)) objDT.Columns.Add("Quantity", GetType(Integer)) objDT.Columns.Add("Cost", GetType(Decimal))

Data Table - Header Row Product Quantity Cost After step 1

Step 2 Adding a new row Dim objDR As System.Data.DataRow objDR = objDT.NewRow Part A – create a new blank row that copies the table

After Step 2a Data Table (objDT)- Header Row Product Quantity Cost DataRow (objDR)

2b – fill the new row objDR("Quantity") = txtQuantity.Text objDR("Product") = ddlProducts.SelectedItem.Text objDR("Cost") = Decimal.Parse(ddlProducts.SelectedItem.Value)

After step 2b Data Table (objDT)- Header Row Product Quantity Cost DataRow (objDR) Something some number some price

Step 3 – put the new row in the table objDT.Rows.Add(objDR)

After step 3 Data Table (objDT) Product Quantity Cost Something some number some price Header Row Row 1

Shopping Basket User not logged in* – Session – Datatable stored in memory User logged in – Session – Datatable to & from database * This version for coursework

Shopping Basket Initialise basket 1.Create a datatable 2.Store it in memory (Session) Session(“cart”)=objDT

Shopping basket (cont 2) When “add to cart” clicked 1.Retrieve the datatable from memory 2.Create a new row 3.Fill in the data 4.Put the new row on the bottom of the datatable basket = Session(“cart”)

Shopping basket (cont 3) View Basket 1.Retrieve table from memory 2.Bind table to DataGrid BasketGrid.DataSource()=Session(“cart”)

TO DO Oasisplus – ASP.NET : INSERT, DELETE, UPDATE – ASP.NET : DataList – Shopping basket example code on discussion board – Or start your coursework NEXT WEEK – SHOPPING BASKET Where we take items from a list retrieved from the database