C#: ADO. net For Beginners

所在平台: Udemy

课程主页: https://www.udemy.com/course/crud-operation-projects-using-adonet/

课程评论:没有评论

第一个写评论        关注课程

课程简介

**课程名称:** C#: ADO.NET 入门 **课程概述:** 本课程是关于 C# 中 ADO.NET 的入门指南。ADO.NET 是一个包含一系列类(一个框架)的集合,用于与数据库和 XML 文件等数据源进行交互。ADO 是 ActiveX Data Objects 的缩写,它允许我们连接到底层数据或数据库,并提供类和方法来检索和操作数据。 **ADO.NET 的应用范围:** ADO.NET 被广泛应用于各种 .NET 应用程序中,包括: * ASP.NET Web 应用程序 * 控制台应用程序 * Windows 应用程序 **连接架构:** 本课程将介绍两种主要的连接架构: 1. **连接式架构 (Connected Architecture):** 应用程序在整个处理过程中始终与数据库保持连接。 2. **非连接式架构 (Disconnected Architecture):** 应用程序在处理过程中会根据需要自动连接和断开与数据库的连接。在此架构下,应用程序通常使用名为 `DataSet` 的临时数据结构来存储数据。 **ADO.NET 中的重要类:** 课程重点介绍 ADO.NET 中的几个核心类: 1. **Connection 类 (Connection Class):** * 用于连接到数据库。 * 负责管理事务和连接池。 2. **Command 类 (Command Class):** * 提供存储和执行 SQL 语句以及存储过程的方法。 * **重要方法:** * `ExecuteReader`:以行的方式将数据返回给客户端,通常用于 `SELECT` 语句,返回 `DataReader` 对象。 * `ExecuteNonQuery`:执行修改数据库数据的命令(如 `UPDATE`、`DELETE`、`INSERT`),返回受影响的行数。 * `ExecuteScalar`:只返回单个值,通常用于计数或计算。 * `ExecuteXMLReader` (仅限 `SqlClient` 类):使用 XML 流从 SQL Server 2000 数据库获取数据,并返回 `XML Reader` 对象。 3. **DataReader 类 (DataReader Class):** * 用于检索数据。 * 与 `Command` 类结合使用,执行 `SELECT` 语句并访问返回的行。 4. **DataAdapter 类 (DataAdapter Class):** * 用于将 `DataSet` 与数据库连接。 * 在 Windows 窗体中使用数据绑定控件时特别有用,也可用于管理应用程序与数据库表、视图和存储过程之间的连接。 5. **DataSet 类 (DataSet Class):** * 是 ADO.NET 的核心。 * 本质上是一系列 `DataTable` 对象的集合。 * 每个 `DataTable` 对象又包含 `DataColumn` 和 `DataRow` 对象的集合。 * `DataSet` 还包含 `Relations` 集合,可用于定义 `DataTable` 对象之间的关系。 **课程内容总结:** 本课程将带领初学者深入了解 ADO.NET 的基础知识,包括其在 .NET 应用程序中的应用、不同的连接架构以及 ADO.NET 中的关键类(Connection, Command, DataReader, DataAdapter, DataSet)及其功能用法。理解和掌握这些概念对于进行数据访问和管理至关重要。

课程评论(0条)

课程详情

ADODotNET is a set of classes (a framework) to interact with data sources such as databases and XML files. ADO is the acronym for ActiveX Data Objects. It allows us to connect to underlying data or databases. It has classes and methods to retrieve and manipulate data.The following are a few of the dot NET applications that use ADODotNET to connect to a database, execute commands and retrieve data from the database.ASP.NET Web ApplicationsConsole Applications Windows Applications.Various Connection ArchitecturesThere are the following two types of connection architectures: Connected architecture: the application remains connected with the database throughout the processing. Disconnected architecture: the application automatically connects/disconnects during the processing. The application uses temporary data on the application side called a DataSetImportant Classes in ADODotNETWe can also observe various classes in the preceding diagram. They are:Connection ClassCommand ClassDataReader ClassDataAdaptor ClassDataSet Class 1. Connection ClassIn ADODotNET, we use these connection classes to connect to the database. These connection classes also manage transactions and connection pooling. To learn more about connection classes, start here: Connection in ADODotNET 2. Command ClassThe Command class provides methods for storing and executing SQL statements and Stored Procedures. The following are the various commands that are executed by the Command Class.ExecuteReader: Returns data to the client as rows. This would typically be an SQL select statement or a Stored Procedure that contains one or more select statements. This method returns a DataReader object that can be used to fill a DataTable object or used directly for printing reports and so forth.ExecuteNonQuery: Executes a command that changes the data in the database, such as an update, delete, or insert statement, or a Stored Procedure that contains one or more of these statements. This method returns an integer that is the number of rows affected by the query.ExecuteScalar: This method only returns a single value. This kind of query returns a count of rows or a calculated value.ExecuteXMLReader: (SqlClient classes only) Obtains data from an SQL Server 2000 database using an XML stream. Returns an XML Reader object. 3. DataReader ClassThe DataReader is used to retrieve data. It is used in conjunction with the Command class to execute an SQL Select statement and then access the returned rows. Learn more here: Data Reader in C#. 4. DataAdapter ClassThe DataAdapter is used to connect DataSets to databases. The DataAdapter is most useful when using data-bound controls in Windows Forms, but it can also be used to provide an easy way to manage the connection between your application and the underlying database tables, views and Stored Procedures. Learn more here: Data Adapter in ADODotNET 5. DataSet ClassThe DataSet is the heart of ADODotNET. The DataSet is essentially a collection of DataTable objects. In turn each object contains a collection of DataColumn and DataRow objects. The DataSet also contains a Relations collection that can be used to define relations among Data Table Objects.

课程标签

0人关注该课程

主题相关的课程