ExecuteScalar函数功能有哪些?

ExecuteScalar函数功能有哪些?

OleDbCommand.ExecuteScalar Method

MSDN 资料

Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

Namespace: System.Data.OleDb
Assembly: System.Data (in system.data.dll)

用处: 查询数据库总记录数

ExecuteScalar函数功能有哪些?stringquerystr="selectcount(*)FromConanMsg";
ExecuteScalar函数功能有哪些?OleDbCommandmycommand;
ExecuteScalar函数功能有哪些?mycommand
=newOleDbCommand(querystr,myconn);
ExecuteScalar函数功能有哪些?
intcount=(int)mycommand.ExecuteScalar();

count里保存的就是总记录数.