Sunteți pe pagina 1din 20

Lp trnh Web

Chng: 15

ADO.NET Fundamentals
1 Lp trnh Web

Ni dung
Understanding Data Management

Configuring Your Database


SQL Basics ADO.NET Basics Direct Data Access Disconnected Data Access

Lp trnh Web

Understanding Data Management


Reference:
Beginning ASP.NET 3.5 in C sharp 2008 From Novice to

Professional, 2nd edittion, Apress ( page 483 486)

Lp trnh Web

Configuring Your Database


SQL Server Express (SV t c ti liu)

Browsing and Modifying Databases in Visual

Studio ( SV t c ti liu) The sqlcmd Command-Line Tool

Lp trnh Web

The sqlcmd Command-Line Tool


Sqlcmd.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 its found in a directory like c:\Program Files\Microsoft SQL Server\90\Tools\Binn
To see all the possible parameters, type this command:

sqlcmd -?
Lp trnh Web

The sqlcmd Command-Line Tool

Lp trnh Web

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

Lp trnh Web

SQL Basics
Running Queries in Visual Studio

The Select Statement


The SQL Update Statement The SQL Insert Statement The SQL Delete Statement

Lp trnh Web

ADO.NET Basics
Data Namespaces

The Data Provider Classes

Lp trnh Web

Data Namespaces
Namespace System.Data Purpose Contains fundamental classes with the core ADO.NET functionality. This includes DataSet and DataRelation, 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. Contains the classes you use to connect to an OLE DB data source and execute commands,
Lp trnh Web

System.Data.Common

System.Data.OleDb

10

Data Namespaces
Namespace System.Data.SqlClient Purpose Contains the classes you use to connect to a Microsoft SQL Server database (version 7.0 or later) and execute commands. Contains structures for SQL Serverspecific data types such as SqlMoney and SqlDateTime. Contains the classes you use to connect to a data source through an ODBC driver and execute commands
Lp trnh Web

System.Data.SqlTypes

System.Data.Odbc

11

The Data Provider Classes


SQL Server Data Provider OLE DB Data Provider Oracle Data Provider ODBC Data Provider

Connection

SqlConnection

OleDbConnect OracleConnec ion tion

OdbcConnecti on

Command DataReader DataAdapter

Lp trnh Web

12

Direct Data Access


Creating a Connection

The Select Command


The DataReader Lab

13

Lp trnh Web

Lab
To trang qun l thng tin Nhn vin ( xem, thm, xa,

sa)

Lp trnh Web

14

Disconnected Data Access

15

Lp trnh Web

The DataSet family of objects

Lp trnh Web

16

Selecting Disconnected Data

Lp trnh Web

17

Selecting Multiple Tables

Lp trnh Web

18

Defining Relationships

Lp trnh Web

19

Lab
To trang xem thng tin phn quyn nhn vin.

Lp trnh Web

20

S-ar putea să vă placă și