ASP.NET and database knowledge points (1)

1: What is Ado.Net?
A data access library access technology, the application can connect to the database and operate the data in various ways. A COM component library, data in .Net, preferred database interface
2: ADO (ActiveX Data Objects) components used by early developers to access data. .net Ado.Net gradually replaced Ado.
3: The relationship between them?
Ado.Net is an upgraded version of ADO. Strictly speaking, they are two completely different methods.
Technically, the Ado oledb interface is based on the COM technology
. Ado.Net has its own interface, based on the .Net architecture.

System.Data.dll, System.Data namespace, provides different Ado.Net classes
Composition:
1: DataSet: non-connected core components. Data access independent of any data source, a variety of different data sources
2: Data Provider (data provider): used to connect to the database, execute commands, and retrieve results.
SqlServer Database Provider System.Data.SqlClient Namespace Data
Provider for OLEDB System.Data.Oledb Namespace
Database Provider for ODBC System.Data.Odbc Namespace
Oracle Data Provider System.Data.OracleClient Namespace

Connection provides a connection with the database source Sqlconnection
Command executes the database command object SqlCommand
DataReader provides a fast, read-only data stream from the data source SqlDataReader
DataAdapter provides a bridge between the DataSet object and the data source. Fill Update

Steps for Ado.Net to access data
Connect to the database Open the connection Create and execute the command object (create command) Execute the command to close the connection The
Sqlconnection class inherits from the DbConnection abstract base class and cannot be instantiated. Provides a connection to the SqlServer database

Commonly used properties
SqlConnection conn = new SqlConnection();
//Open the door - key, connection string - key
conn.ConnectionString = "";//Connection string
//conn.Database; Database name to be connected
//conn.DataSource; Data source local .Ip, port number
//conn.State; Connect to state
// conn.ConnectionTimeout; 15s

State: Closed Open Open Connecting Connecting Executing
Executing Command Fetching Retrieving Broken Connection Interrupted
Commonly used methods:
//2: Open the connection conn.Open();
//5 Close the connection;
conn.Close();//Close the connection
conn.Dispose();//Release the connection

        //差别:Close()后还可以再打开;连接字符串还有
        //Dispose()后,连接字符串也没有,为空,重新设置连接字符串
        ![在这里插入图片描述](https://img-blog.csdnimg.cn/85f0820eb9dc417cae1913ad65e079df.png#pic_center)

Guess you like

Origin blog.csdn.net/m0_46454966/article/details/127467395