SqlDataSourceCommandType Enum
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menjelaskan jenis perintah SQL yang digunakan oleh kontrol SqlDataSource dan AccessDataSource saat melakukan operasi database.
public enum class SqlDataSourceCommandType
public enum SqlDataSourceCommandType
type SqlDataSourceCommandType =
Public Enum SqlDataSourceCommandType
- Warisan
Bidang
| Nama | Nilai | Deskripsi |
|---|---|---|
| Text | 0 | Teks yang terkandung dalam properti teks yang sesuai adalah kueri atau perintah SQL. |
| StoredProcedure | 1 | Teks yang terkandung dalam properti teks yang sesuai adalah nama prosedur tersimpan. |
Contoh
Contoh kode berikut menunjukkan cara mengatur SelectCommand teks ke nama prosedur tersimpan dan SelectCommandType properti ke nilai StoredProcedure untuk mengambil data dari database Microsoft SQL Server dan menampilkannya dalam DropDownList.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList
id="DropDownList1"
runat="server"
DataTextField="LastName"
DataSourceID="SqlDataSource1" />
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommandType="StoredProcedure"
SelectCommand="sp_lastnames">
</asp:SqlDataSource>
<!--
The sp_lastnames stored procedure is
CREATE PROCEDURE sp_lastnames AS
SELECT LastName FROM Employees
GO
-->
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ASP.NET Example</title>
</head>
<body>
<form id="form1" runat="server">
<asp:DropDownList
id="DropDownList1"
runat="server"
DataTextField="LastName"
DataSourceID="SqlDataSource1" />
<asp:SqlDataSource
id="SqlDataSource1"
runat="server"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommandType = "StoredProcedure"
SelectCommand="sp_lastnames">
</asp:SqlDataSource>
<!--
The sp_lastnames stored procedure is
CREATE PROCEDURE sp_lastnames AS
SELECT LastName FROM Employees
GO
-->
</form>
</body>
</html>
Keterangan
SqlDataSourceCommandType Enumerasi digunakan oleh SqlDataSource kontrol dan AccessDataSource untuk menjelaskan jenis perintah SQL yang terkandung dalam SelectCommandproperti , , InsertCommandUpdateCommand, dan DeleteCommand . Nilai Teks menunjukkan bahwa teks adalah kueri SQL atau string perintah sementara nilai StoredProcedure menunjukkan bahwa teks adalah nama prosedur tersimpan.