SqlDataSourceMode 列挙型
定義
SqlDataSource コントロールまたは AccessDataSource コントロールの使用時に、データを IDataReader として取得するか、DataSet として取得するかを指定します。Specifies whether a SqlDataSource or AccessDataSource control retrieves data as a IDataReader or DataSet.
public enum class SqlDataSourceMode
public enum SqlDataSourceMode
type SqlDataSourceMode =
Public Enum SqlDataSourceMode
- 継承
フィールド
DataReader | 0 | 基になるデータ ストレージから、データを IDataReader として取得します。Retrieves data from the underlying data storage as an IDataReader |
DataSet | 1 | 基になるデータ ストレージから DataSet 構造体にデータを取得します。Retrieves data from the underlying data storage into a DataSet structure. |
例
次の例では、 DataSourceMode SqlDataSource DataReader
SQL Server データベースからコントロールに項目の単純なリストを取得するときに、コントロールのプロパティをに設定する方法を示し ListBox ます。The following example demonstrates how to set the DataSourceMode property of a SqlDataSource control to DataReader
when retrieving a simple list of items from a SQL Server database into a ListBox control.
<%@ Page language="C#" %>
<!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:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataReader"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommand="SELECT LastName FROM Employees">
</asp:SqlDataSource>
<asp:ListBox
id="ListBox1"
runat="server"
DataTextField="LastName"
DataSourceID="SqlDataSource1">
</asp:ListBox>
</form>
</body>
</html>
<%@ Page language="VB" %>
<!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:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataReader"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommand="SELECT LastName FROM Employees">
</asp:SqlDataSource>
<asp:ListBox
id="ListBox1"
runat="server"
DataTextField="LastName"
DataSourceID="SqlDataSource1">
</asp:ListBox>
</form>
</body>
</html>
次の例では、 SqlDataSource.DataSourceMode DataSet
GridView 並べ替えが有効になっているコントロールにデータのセットを取得するときに、プロパティをに設定する方法を示します。The following example demonstrates how to set the SqlDataSource.DataSourceMode property to DataSet
when retrieving a set of data into a GridView control that has sorting enabled.
<!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:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataSet"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
</asp:SqlDataSource>
<asp:GridView
id="GridView1"
runat="server"
AllowSorting="True"
DataSourceID="SqlDataSource1">
</asp:GridView>
</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:SqlDataSource
id="SqlDataSource1"
runat="server"
DataSourceMode="DataSet"
ConnectionString="<%$ ConnectionStrings:MyNorthwind%>"
SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
</asp:SqlDataSource>
<asp:GridView
id="GridView1"
runat="server"
AllowSorting="True"
DataSourceID="SqlDataSource1">
</asp:GridView>
</form>
</body>
</html>
注釈
SqlDataSourceMode
列挙体は、 SqlDataSource AccessDataSource メソッドが呼び出されたときにデータソースコントロールが使用するデータ取得モードを記述するために、コントロールおよびコントロールによって使用され Select ます。The SqlDataSourceMode
enumeration is used by the SqlDataSource and AccessDataSource controls to describe the data retrieval mode that the data source control uses when the Select method is called. DataSourceModeプロパティがに設定されている場合 DataSet
、データは DataSet 構造体に読み込まれます。When the DataSourceMode property is set to DataSet
, data is loaded into a DataSet structure. これにより、などのユーザーインターフェイスコントロールが GridView 並べ替えやページング機能を提供できるようになります。This enables scenarios where user interface controls such as GridView offer sorting and paging capabilities. DataSourceModeプロパティがに設定され DataReader
ている場合、データは IDataReader 読み取り専用の順方向専用カーソルであるオブジェクトによって取得されます。When the DataSourceMode property is set to DataReader
, data is retrieved by an IDataReader object, which is a read-only, forward-only cursor.
SqlDataSourceMode
列挙体は、コマンドがデータを取得する方法を説明するためだけに使用され Select ます。コントロールが実行する他の操作 (、、など) には影響しません。 SqlDataSource Insert Update DeleteThe SqlDataSourceMode
enumeration is only used to describe how the Select command retrieves data; it has no effect on other operations the SqlDataSource control performs, such as Insert, Update, or Delete.