The ADO data provider has three SQL Server data providers, OLE DB providers, and ODBC providers, respectively.
This record is a few of the knowledge points in the SQL Server provider.
①sqldatareader must be instantiated by SqlCommand call DataReader. This class is characterized by a read-only, fast access speed.
The Read method pulls the data from the data source, and only one record (read-only) is fetched per read, during which time the local DataReader does not cache the data while maintaining a connection to the database. When retrieving large amounts of data, the speed is very good. It is important to close the current database connection when Sqldatareader.read () ==false, that is, there is no matching data.
In the SqlDataReader class, there are a lot of ways to get worthwhile methods, such as GetSqlInt32 (), Getsqlvalue (), Getsqlmoney (), which provide a good performance for these systems. (can avoid unnecessary packing, unpacking operation)
SqlDataReader dataReader = command. ExecuteReader ();
if (datareader.hasrows)
{
while (Datareader.read ())
{
var a = datareader.getint32 (0);
}
}
②sqldataadapter, this class has multiple construction methods. Simply say it. There are several command forms: Selectcommand,updatecommand,insertcommand,deletecommand, which need to set the response SQL statement in order to respond to the action.
ADO SqlDataReader Detailed