What is CommandType in SqlCommand?

Updated Apr 28, 2026

Short answer

It specifies how the command text should be interpreted (Text, StoredProcedure, TableDirect).

Deep explanation

CommandType.Text executes raw SQL; StoredProcedure executes stored procedures; TableDirect accesses table directly (rarely used).

Real-world example

Executing stored procedures for business logic.

Common mistakes

  • Forgetting to set correct CommandType.

Follow-up questions

  • Why use stored procedures?
  • Default CommandType?

More ADO.NET interview questions

View all →