SqlDataSourceMode 列挙体とは? わかりやすく解説

SqlDataSourceMode 列挙体

メモ : この列挙体は、.NET Framework version 2.0新しく追加されたものです。

SqlDataSource コントロールまたは AccessDataSource コントロール使用時に、データを IDataReader として取得するか、DataSet として取得するかを指定します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As SqlDataSourceMode
public enum SqlDataSourceMode
public enum class SqlDataSourceMode
public enum SqlDataSourceMode
public enum SqlDataSourceMode
メンバメンバ
 メンバ説明
DataReader基になるデータ ストレージから、データIDataReader として取得します。 
DataSet基になるデータ ストレージから DataSet 構造体データ取得します。 
解説解説

SqlDataSourceMode 列挙体は、Select メソッド呼び出し時にデータ ソース コントロール使用するデータ取得モード定義する際に、SqlDataSource コントロールおよび AccessDataSource コントロールによって使用されます。DataSourceMode プロパティDataSet設定した場合データDataSet 構造体読み込まれます。これにより、GridView などのユーザー インターフェイス コントロールに、並べ替え機能ページング機能実装できますDataSourceMode プロパティを DataReader に設定した場合読み取り専用で、前方カーソルIDataReader オブジェクトによってデータ取得されます。

SqlDataSourceMode 列挙体は、Select コマンドどのようにデータ取得するかを定義する目的でのみ使用しますInsertUpdateDelete など、SqlDataSource コントロールによって実行されるその他の操作には影響しません。

使用例使用例

SqlDataSource コントロールDataSourceModeDataReader設定しSQL Server データベースから ListBox コントロール単純な項目リスト取得する方法次のコード例示します

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
  <BODY>
    <FORM 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="CS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
  <BODY>
    <FORM 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>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
  <BODY>
    <FORM runat="server">
      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataReader"
          ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial
 Catalog=Northwind;"
          SelectCommand="SELECT LastName FROM Employees">
      </asp:SqlDataSource>

      <asp:ListBox
          id="ListBox1"
          runat="server"
          DataTextField="LastName"
          DataSourceID="SqlDataSource1">
      </asp:ListBox>

    </FORM>
  </BODY>
</HTML>

DataSourceModeDataSet設定し並べ替え機能を持つ GridView コントロールデータ セット取得する方法次のコード例示します

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML>
  <BODY>
    <FORM 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>
  <BODY>
    <FORM 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>
  <BODY>
    <FORM runat="server">

      <asp:SqlDataSource
          id="SqlDataSource1"
          runat="server"
          DataSourceMode="DataSet"
          ConnectionString="Data Source=localhost;Integrated Security=SSPI;Initial
 Catalog=Northwind;"
          SelectCommand="SELECT FirstName, LastName, Title FROM Employees">
      </asp:SqlDataSource>

      <asp:GridView
          id="GridView1"
          runat="server"
          AllowSorting="True"
          DataSourceID="SqlDataSource1">
      </asp:GridView>

    </FORM>
  </BODY>
</HTML>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Web.UI.WebControls 名前空間
SqlDataSource.DataSourceMode プロパティ
Select



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「SqlDataSourceMode 列挙体」の関連用語

SqlDataSourceMode 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



SqlDataSourceMode 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS