user1657851
user1657851

Reputation: 1

Concern ADO.net Command

I want execute the following command text(sql statement) which command I need to use?

command.CommandText="select Fname from table_name where Lname='abc'"

I need to use ExecutScalar or ExecuteReader command, could you please confirm.

Upvotes: 0

Views: 87

Answers (1)

podiluska
podiluska

Reputation: 51514

Either will work. It depends on the expected results.

If you are only returning a single value, ExecuteScalar would be preferred.

Otherwise, use ExecuteReader or fill a DataTable

Upvotes: 2

Related Questions