dongtang1944 2014-04-09 22:56
浏览 26
已采纳

c#和SQL服务器相当于PHP中的mysql_num_rows

I am trying to find the number of rows selected by a select query in ASP.Net - I am using an SQL server database. What is the c# equivalent to PHP's mysql_num_rows?

  • 写回答

3条回答 默认 最新

  • dsvjmc0907 2014-04-09 23:02
    关注

    System.Data.SqlClient

    SqlDataReader has the RecordsAffected Property to get that value, except for select statements. Therefore you have to count manually or use a SELECT COUNT(*) in your SQL statement.

    EntityFramework

    Have a look a this article.

    LINQ2SQL

    var pupilCOunt = (from p in schoolContext.Pupils select p).Count();

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误