Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道这不是一个非常有用的问题,但我不禁被它困扰。
那么, 为什么所说的方法(在*Command类中)被称为 ExecuteNonQuery而不是ExecuteQuery?
*Command
我们扔给数据库的那些 SQL 语句不就是查询吗?
从语义上讲,查询是您执行以返回数据的东西。您正在“查询”数据库以查找 Y 中的所有 X。
如果您不期望返回结果,则与其说是查询,不如说是语句或命令。
如果它们是 INSERTs、DELETEs、CREATE TABLEs 等,则不是。
我会认为它是一个查询,要求数据库返回记录。更改数据/数据库的操作不会是查询。