ExecuteScalar is typically used when your query returns a single value. If it returns more, then the result is the first column of the first row. An example might be SELECT @@IDENTITY AS 'Identity'. ExecuteReader is used for any result set with multi…
using System.Data.SqlClient;...SqlConnection conn = new SqlConnection(@"server=ws7\leosql;database=AdventureWorks;uid=sa;pwd=lixiang@");try{ conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM Person.Address", conn); S…
下面我将详细讲解在机房收费系统D层中如何对数据库的增加.删除.修改,最后再来总结一下 ExecuteNonQuery(),ExecuteScalar(),ExecuteReader的用法: 一.增.删.改 1. 增加新的记录 Private Sub frmAddUser_Load(sender As Object, e As EventArgs) Handles MyBase.Load { MyConnection.Open();’打开数据库 MyCommand1.CommandText="In…
引用自:http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/ Understanding how SQL Server executes a query August 1st, 2013 If you are a developer writing applications that use SQL Server and you are wondering what exactly happens…