JavaScript is required

Để thực thi một Procudure có sẵn trong cơ sở dữ liệu SQL Server ta cần thiết lập thuộc tính CommandType của đối tượng SqlCommand bằng giá trị nào trong các giá trị sau?

A.

CommandType.Sql

B.

CommandType.Text.

C.

CommandType.Procedure.

D.

CommandType.StoredProcedure.

Trả lời:

Đáp án đúng: D


Trong SQL Server, để gọi một stored procedure (thủ tục lưu trữ) có sẵn trong cơ sở dữ liệu, chúng ta phải chỉ định CommandType của SqlCommand là StoredProcedure. Vì vậy, đáp án đúng là D.

  • CommandType.Text: Sử dụng khi chúng ta muốn thực thi một câu lệnh SQL trực tiếp.
  • CommandType.TableDirect: Sử dụng để truy xuất tất cả dữ liệu từ một bảng.
  • CommandType.StoredProcedure: Sử dụng để gọi một stored procedure.

Câu hỏi liên quan