如何计算c#.net中oledbconnection的总行数
如何计算 c#.net 中 oledbconnection 中的总行数
我想计算表中存在多少行。
string dataReader = "SELECT count(*) from `Email_account_list`";
OleDbCommand command_reader = new OleDbCommand(dataReader, myConnection);
OleDbDataReader row_reader = command_reader.ExecuteReader();
我将编写什么函数来获取表中存在的总行数。
how to count the total number of row in oledbconnection in c#.net
I want to count how many rows are present in my table.
string dataReader = "SELECT count(*) from `Email_account_list`";
OleDbCommand command_reader = new OleDbCommand(dataReader, myConnection);
OleDbDataReader row_reader = command_reader.ExecuteReader();
What function i will write to fetch total number of rows present in table.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SELECT COUNT(*)
语句是一种特殊的 (SELECT) 语句,您不应使用ExecuteReader()
而应使用int rowCount = (int) 命令.ExecuteScalar();
A
SELECT COUNT(*)
statetment is a special (SELECT) statement in that you should not useExecuteReader()
but instead useint rowCount = (int) command.ExecuteScalar();
首先在 OleDbCommand 中使用“Select count(*) ...”。这将使您了解在下一个“Select * ...”中预期的行数。
Use "Select count(*) ..." first in your OleDbCommand. This will give you an idea of the number of rows you could expect in the next "Select * ...".