首頁  >  文章  >  運維  >  如何分析DataSet物件及使用

如何分析DataSet物件及使用

王林
王林轉載
2023-05-16 11:55:061031瀏覽
DataSet物件的概念:

DataSet物件可以視為一個(Catch),它可以吧從資料庫中所查到的資料保留下來,甚至可以將整個資料庫暫存起來

DataSet是資料在記憶體中的表示形式

DataSet物件和資料來源的線上發生的很短暫,我們在取得資料後就立即和資料來源都斷開了,等到資料修改完畢或是要操作資料來源內的資料時才會再建立連線

DataSet物件包含一組DataTable物件和DataRelation物件

DataTable物件及使用

 DataTable物件是DataSet的重要對象之一,表示記憶體中的一個關聯式資料表

DataTable物件的常用屬性

TableName:取得或設定表的名稱

DataSet:指出表格屬於哪一個DataSet

Rows(Add,InsertAt,Remove,RemoveAt):DataRow物件集合,即表示這個表的行的集合

Columns:Data Columns物件集合,即表示這個表的列的集合

範例:

DataSetds = new DataSet();

       DataTable student = new DataTable("Student");

    "Sno");

       sno.DataType = typeof(string);

       sno.MaxLength = 8;##>#ColumData

##       sno.DataType = typeof(string);

       sno.MaxLength = 8;

  ns .Add(sname);

       ds.Tables.Add(student);

       DataRow drl = student.New 0125";

       drl["Sname"] = "李爽";

       student.Rows .drl);

##   st.

       drl["Sno"] = "0125x";

       drl["Sname"] = "x李爽」;#Addd#1;

       GridView1.DataSource = ds.Tables[0];

       GridView1.DataBind();

以上是如何分析DataSet物件及使用的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:yisu.com。如有侵權,請聯絡admin@php.cn刪除