Ado.net fundamentals

20
Chương: 15 ADO.NET Fundamentals Lập trình Web Lập trình Web 1 Lập trình Web

Transcript of Ado.net fundamentals

Page 1: Ado.net fundamentals

Chương: 15

ADO.NET Fundamentals

Lập trình Web Lập trình Web

1 Lập trình Web

Page 2: Ado.net fundamentals

Nội dungNội dungUnderstanding Data ManagementConfiguring Your DatabaseSQL BasicsADO.NET BasicsDirect Data AccessDisconnected Data Access

Lập trình Web 2

Page 3: Ado.net fundamentals

Understanding Data ManagementUnderstanding Data ManagementReference:

Beginning ASP.NET 3.5 in C sharp 2008 From Novice to Professional, 2nd edittion, Apress ( page 483 – 486)

Lập trình Web 3

Page 4: Ado.net fundamentals

Configuring Your Configuring Your DatabaseDatabaseSQL Server Express (SV tự đọc tài liệu)Browsing and Modifying Databases in Visual Studio ( SV tự đọc tài liệu)The sqlcmd Command-Line Tool

Lập trình Web4

Page 5: Ado.net fundamentals

The sqlcmd Command-Line ToolThe sqlcmd Command-Line ToolSqlcmd.exe is the tools that you can use to perform

database tasks from a Windows command prompt

The sqlcmd tool is installed as part of SQL Server 2005 (and 2008), and it’s found in a directory like c:\Program Files\Microsoft SQL Server\90\Tools\Binn

To see all the possible parameters, type this command:

Lập trình Web 5

sqlcmd -?

Page 6: Ado.net fundamentals

The sqlcmd Command-Line ToolThe sqlcmd Command-Line Tool

Lập trình Web 6

Page 7: Ado.net fundamentals

Example:Example:

Lập trình Web 7

sqlcmd -S .\Sqlexpress -U sa -P 123 -i BanSach.sql

Page 8: Ado.net fundamentals

SQL BasicsSQL BasicsRunning Queries in Visual StudioThe Select StatementThe SQL Update StatementThe SQL Insert StatementThe SQL Delete Statement

Lập trình Web8

Page 9: Ado.net fundamentals

ADO.NET BasicsADO.NET BasicsData NamespacesThe Data Provider Classes

Lập trình Web9

Page 10: Ado.net fundamentals

Data NamespacesData NamespacesNamespace Purpose

System.Data Contains fundamental classes with the core ADO.NET functionality. This includes DataSet and DataRelation,

System.Data.Common

Not used directly in your code. These classes are used by other data provider classes that inherit from them and provide versions customized for a specific data source.

System.Data.OleDb Contains the classes you use to connect to an OLE DB data source and execute commands,

Lập trình Web 10

Page 11: Ado.net fundamentals

Data NamespacesData NamespacesNamespace Purpose

System.Data.SqlClient

Contains the classes you use to connect to a Microsoft SQL Server database (version 7.0 or later) and execute commands.

System.Data.SqlTypes

Contains structures for SQL Server–specific data types such as SqlMoney and SqlDateTime.

System.Data.Odbc Contains the classes you use to connect to a data source through an ODBC driver and execute commands

Lập trình Web 11

Page 12: Ado.net fundamentals

The Data Provider ClassesThe Data Provider ClassesSQL Server DataProvider

OLE DB Data Provider

Oracle Data Provider

ODBC Data Provider

Connection SqlConnection OleDbConnection

OracleConnection

OdbcConnection

Command

DataReaderDataAdapter

Lập trình Web 12

Page 13: Ado.net fundamentals

Direct Data AccessDirect Data AccessCreating a ConnectionThe Select CommandThe DataReaderLab

Lập trình Web13

Page 14: Ado.net fundamentals

LabLabTạo trang quản lý thông tin Nhân viên ( xem, thêm, xóa,

sửa)

Lập trình Web 14

Page 15: Ado.net fundamentals

Disconnected Data AccessDisconnected Data Access

Lập trình Web15

Page 16: Ado.net fundamentals

The DataSet family of objectsThe DataSet family of objects

Lập trình Web 16

Page 17: Ado.net fundamentals

Selecting Disconnected DataSelecting Disconnected Data

Lập trình Web 17

Page 18: Ado.net fundamentals

Selecting Multiple TablesSelecting Multiple Tables

Lập trình Web 18

Page 19: Ado.net fundamentals

Defining RelationshipsDefining Relationships

Lập trình Web 19

Page 20: Ado.net fundamentals

LabLabTạo trang xem thông tin phân quyền nhân viên.

Lập trình Web 20