0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • 1
    Welcome to StackOverflow. What happens when you try one of them? Does it work? If not, what happens when you try the other one? – Ken White Sep 09 '12 at 08:23
  • i am confusing with the answer,my scenario is i want display Lname based on Fname and display Lname in the label – user1657851 Sep 09 '12 at 08:32

1 Answers1

2

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

podiluska
  • 50,950
  • 7
  • 98
  • 104
  • i am confusing with the answer,my scenario is i want display Lname based on Fname and display Lname in the label – user1657851 Sep 09 '12 at 08:30