在说C#操作数据库之前需要先说下ADO.NET.ADO.NET的名称起源于ADO(ActiveX Data Objects),是一个COM组件库,用于在以往的Microsoft技术中访问数据.之所以使用ADO.NET名称,是因为Microsoft希望表明,这是在NET编程环境中优先使用的数据访问接口. ADO.NET可让开发人员以一致的方式存取资料来源(例如 SQL Server 与 XML),以及透过 OLE DB 和 ODBC 所公开的资料来源.资料共用的消费者应用程序可使用ADO.NET…
ADO.NET Connection Pooling at a Glance Establishing a connection with a database server is a hefty and high resource consuming process. If any application needs to fire any query against any database server, we need to first establish a connection wi…
相关知识: 有些SQL操作,例如SUM,只会从数据库返回一个数据值,而不是多行数据 尽管也可以使用ExecuteReader()返回一个DataReader对象,代表该数据值,但是使用Command对象的ExecuteScalar方法更加方便 ExecuteScalar()方法:该方法只能执行SELECT语句,通常用于统计,例如返回符合条件的记录个数 代码示例: using System; using System.Collections.Generic; using System.Linq;…