66
ADO.NET FUNDAMENTALS BEGINNING ASP.NET 3.5 IN C#

Ado fundamentals

  • Upload
    crete

  • View
    71

  • Download
    1

Embed Size (px)

DESCRIPTION

Ado.net fundamentals. Beginning asp.net 3.5 in c# . What is ADO.net. ADO.NET is the technology that .NET applications use to interact with database. Data binding is a powerful and practical feature Not easy, must have solid grasp of ADO.NET fundamentals. Understanding data management. - PowerPoint PPT Presentation

Citation preview

Page 1: Ado fundamentals

ADO.NET FUNDAMENTALSBEGINNING ASP.NET 3.5 IN C#

Page 2: Ado fundamentals

WHAT IS ADO.NET

• ADO.NET is the technology that .NET applications use to interact with database.

• Data binding is a powerful and practical feature

• Not easy, must have solid grasp of ADO.NET fundamentals

Page 3: Ado fundamentals

UNDERSTANDING DATA MANAGEMENT

Page 4: Ado fundamentals

THE ROLE OF THE DATABASE

• Adding database to VS2013

Page 5: Ado fundamentals
Page 6: Ado fundamentals
Page 7: Ado fundamentals
Page 8: Ado fundamentals
Page 9: Ado fundamentals
Page 10: Ado fundamentals
Page 11: Ado fundamentals
Page 12: Ado fundamentals
Page 13: Ado fundamentals
Page 14: Ado fundamentals

ADO.NET BASICS

Page 15: Ado fundamentals

TWO GROUPS OF CLASSES

• Contain and manage data

• DataSet, DataTable, DataRow, and DataRelation

• Generic

• Connect to specific data source

• Connection, Command, and DataReader

• Data providers

Page 16: Ado fundamentals
Page 17: Ado fundamentals

DATA NAMESPACES

Page 18: Ado fundamentals
Page 19: Ado fundamentals

DATA PROVIDER CLASSES

• Data classes can’t accomplish much

• Data access is needed see table below

Page 20: Ado fundamentals

DIRECT DATA ACCESS

• The easiest to connect to the database

• Steps1. Create Connection, Command, and DataReader objects.

2. Use the DataReader to retrieve information from the database, and display it in a control on a web form.

3. Close your connection.

4. Send the page to the user. At this point, the information your user sees and the information in the database no longer have any connection, and all the ADO.NET objects have been destroyed.

To add or update information, follow these steps:

5. Create new Connection and Command objects.

6. Execute the Command (with the appropriate SQL statement).

Page 21: Ado fundamentals
Page 22: Ado fundamentals

NAMESPACES NEEDED

using System.Data;

using System.Data.SqlClient;

Page 23: Ado fundamentals

CREATING A CONNECTION

• SQL Server through the OLE DB provider

• Using SqlConnection object from the SQL Server

Page 24: Ado fundamentals

THE CONNECTION STRING

• Data source – name of the server

• Initial catalog – name of the database

• Integrated security – using Windows user account, SSPI (security support provider interface) or SQL server user id and password

• Connection Timeout – how long your code will wait before generating an error

Page 25: Ado fundamentals

STORING THE CONNECTION STRING

• Using a constructor

• Store in web.config

Page 26: Ado fundamentals

• Import it

Page 27: Ado fundamentals

GRIDVIEW EXAMPLE WITH MDF FILE

Page 28: Ado fundamentals
Page 29: Ado fundamentals
Page 30: Ado fundamentals
Page 31: Ado fundamentals
Page 32: Ado fundamentals
Page 33: Ado fundamentals
Page 34: Ado fundamentals
Page 35: Ado fundamentals
Page 36: Ado fundamentals
Page 37: Ado fundamentals
Page 38: Ado fundamentals

Drag GridView

Page 39: Ado fundamentals
Page 40: Ado fundamentals
Page 41: Ado fundamentals

Bind a data source

Page 42: Ado fundamentals
Page 43: Ado fundamentals
Page 44: Ado fundamentals

Download the file from douap.uap.asia

Page 45: Ado fundamentals
Page 46: Ado fundamentals
Page 47: Ado fundamentals

The name to be added in the web.config

Page 48: Ado fundamentals

Shows the columns of the database table

Page 49: Ado fundamentals

Test the connection

Page 50: Ado fundamentals

Adding/modifying the properties

Page 51: Ado fundamentals
Page 52: Ado fundamentals
Page 53: Ado fundamentals
Page 54: Ado fundamentals
Page 55: Ado fundamentals
Page 56: Ado fundamentals
Page 57: Ado fundamentals
Page 58: Ado fundamentals
Page 59: Ado fundamentals
Page 60: Ado fundamentals
Page 61: Ado fundamentals
Page 62: Ado fundamentals
Page 63: Ado fundamentals
Page 64: Ado fundamentals

• Adding theme and AutoGenerateEditButton="true"

Page 65: Ado fundamentals

EXERCISE

• Add insert to the GridView

• Add UpdateCommand

• Add DeleteCommand

Page 66: Ado fundamentals

PROBLEM SET

• Modify the order menu to use mdf files and add CRUD