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.
我想执行以下命令文本(sql语句)我需要使用哪个命令?
command.CommandText="select Fname from table_name where Lname='abc'"
我需要使用 ExecutScalar 或 ExecuteReader 命令,请您确认一下。
要么会工作。这取决于预期的结果。
如果您只返回一个值,ExecuteScalar将是首选。
ExecuteScalar
否则,使用ExecuteReader或填写DataTable
ExecuteReader
DataTable