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.
我在 C# 中有一个应用程序,它在 MySQL 数据库上查询具有特定“代码”/“数字”的员工,但是当用户键入将在查询中使用的代码时,它可能不会返回任何代码不存在。
因此,如果查询没有返回任何内容并且我使用了dataAdapterObj.Fill(dataTableObj);我如何通过填充的 dataTableObj 发现查询是否真的没有返回任何内容?
dataAdapterObj.Fill(dataTableObj);
您只需测试表对象中是否有行:
dataTableObj.Rows.Count == 0
如果这True不是返回的行。否则,您有一些数据。
True