7 DataSet DataSet TableColumnDataSet DataSet NOTE DataSet DataAdapterDataSetDataAdapter DataSet DataSetDataSetDataSet NorthwindDataSet DataSet Dim Nor

Similar documents
Chapter 00 導論

1-1 database columnrow record field 不 DBMS Access Paradox SQL Server Linux MySQL Oracle IBM Informix IBM DB2 Sybase 1-2

1 Framework.NET Framework Microsoft Windows.NET Framework.NET Framework NOTE.NET NET Framework.NET Framework 2.0 ( 3 ).NET Framework 2.0.NET F

Microsoft PowerPoint - VB14.ppt

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

VB控件教程大全

PowerPoint Presentation

2 ADO.NET Internet 1.2

<463A5CC2A4B6ABD1A7D4BA5CBDCCD1A7D6B8C4CFD7DC5CA1B C B3CCD0F2C9E8BCC6A1B7BFCEB3CCD6B8C4CF2E646F63>

幻灯片 1

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

ebook46-23

基于ECO的UML模型驱动的数据库应用开发1.doc

1 1 Excel VBA 說明 ( ) (_) STEP4 Excel 2 STEP5 A1 1 B2 2 C3 3 STEP6 A1 STEP7 > > 1-11

untitled

2 WF 1 T I P WF WF WF WF WF WF WF WF 2.1 WF WF WF WF WF WF

epub83-1

CC213

導讀 ASP.NET HTML ASP 第一篇 基礎篇第 1 章 認識 ASP.NET ASP.NET ASP.NET ASP.NET ASP.NET 第 2 章 認識 Visual Studio 20 開發環境 Visual Studio 20 Visual Studio 20 第二篇 C# 程式

EJB-Programming-3.PDF

Chapter 16 集合

多層次傳銷與獎金系統

PPBSalesDB.doc

投影片 1

基于UML建模的管理管理信息系统项目案例导航——VB篇

概述

IsPostBack 2

AL-M200 Series

Oracle高级复制配置手册_业务广告_.doc

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class

PowerPoint プレゼンテーション

目 录 第 一 部 分 档 案 局 概 况 一 主 要 职 责 二 部 门 决 算 单 位 构 成 第 二 部 分 档 案 局 2016 年 度 部 门 预 算 表 一 2016 年 度 市 级 部 门 收 支 预 算 总 表 二 2016 年 度 市 级 部 门 支 出 预 算 表 三 2016

2015 年 度 收 入 支 出 决 算 总 表 单 位 名 称 : 北 京 市 朝 阳 区 卫 生 局 单 位 : 万 元 收 入 支 出 项 目 决 算 数 项 目 ( 按 功 能 分 类 ) 决 算 数 一 财 政 拨 款 一 一 般 公 共 服 务 支 出 二

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

cm Q 200g 196ml 80g 36g 36g p.31 35ml 6g 2g 1 2 p.39 1~ g 5g1g 96ml 15 25~ g 043

VB程序设计教程

目錄 C ontents Chapter MTA Chapter Chapter

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

ebook

INTRODUCTION TO COM.DOC

Microsoft Word - 11.doc

数 据 库 系 统 基 础 2/54 第 6 章 数 据 库 管 理 与 维 护

epub 94-3

國立中山大學學位論文典藏.PDF

第一章

Microsoft Word - 小心翼翼的二十一點N.doc

untitled

投影片 1

穨文件1

多媒體應用 13 新增專案並完成版面配置 <ExMusic01> <activity_main.xml> ImageView ID imgplay ImageView ID imgstop ImageView ID imgfront TextView ID txtsong TextView ID t

untitled

Microsoft Office SharePoint Server MOSS Web SharePoint Web SharePoint 22 Web SharePoint Web Web SharePoint Web Web f Lists.asmx Web Web CAML f

Visual Basic D 3D

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

TC35短信发送程序设计

RunPC2_.doc

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1.

ebook140-8

輕鬆學 Dreamweaver CS5 網頁設計..\Example\Ch0\ \.html..\example\ch0\ \mouse.txt..\example\ch0\ \ _Ok.html 學習重點 JavaScript 複製程式碼 mouse.txt Ctrl+C Ctrl+C 0-4

<ADB6ADB1C25EA8FAA6DB2D4D56432E706466>

ADO.NET 資料庫存取架構

Multi-national Company Operation and Public...

ActiveX Control

File No. No. 2 No. 3 File No. CONFIDENTIAL 4 7 Chapter Chapter Chapter 3 3.

The golden pins of the PCI card can be oxidized after months or years

untitled

untitled

epub 61-2

untitled

Microsoft Word - 8. 以通俗之教化民成俗:晚明经学家郝敬《圣谕俗讲》.doc

Oracle Oracle Solaris Studio IDE makefile C C++ Fortran makefile IDE Solaris Linux C/C++/Fortran Oracle IDE "P

MVB-1001.DOC

Microsoft Word - 4.doc

终端安全2

终端安全10

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

IP Encoder 1 channel.book

untitled

NEXT SDT2.51 C:\ARM251 SDT2.51 ARM SDT 2.51 ARM PROJECT MANAGER SDT 2

SDS 1.3

What You Can Find with SciFinder Scholar SciFinder Scholar Area Information Available in SciFinder Scholar Document Title Information Author/inventor

3. 反 映 : 4. 五 花 八 门 : 5. 慷 慨 : 6. 参 与 : 7. 慰 劳 : 8. 延 续 : 9. 珍 爱 : 10. 浪 漫 : 三. 找 出 下 列 每 组 词 中 的 近 义 词 或 同 义 词 : 节 日 节 气 节 令 时 节 习 俗 民 俗 仪 式 风 俗 文 献

ThreeDtunnel.doc

92 (When) (Where) (What) (Productivity) (Efficiency) () (2) (3) (4) (5) (6) (7) em-plant( SiMPLE++) Scheduling When Where Productivity Efficiency [5]

untitled

ebook 165-5

untitled

untitled

1 1 大概思路 创建 WebAPI 创建 CrossMainController 并编写 Nuget 安装 microsoft.aspnet.webapi.cors 跨域设置路由 编写 Jquery EasyUI 界面 运行效果 2 创建 WebAPI 创建 WebAPI, 新建 -> 项目 ->

ebook140-9

( Version 0.4 ) 1

Microsoft Word - Datastream5.1_使用說明201110

User’s Manual

mvc

2/14 Buffer I12, /* x=2, buffer = I 1 2 */ Buffer I243, /* x=34, buffer = I 2 43 */ x=56, buffer = I243 Buffer I243I265 code_int(int x, char *buffer)

声 明 本 公 司 及 全 体 董 事 监 事 高 级 管 理 人 员 承 诺 不 存 在 任 何 虚 假 记 载 误 导 性 陈 述 或 重 大 遗 漏, 并 对 其 真 实 性 准 确 性 完 整 性 承 担 个 别 和 连 带 的 法 律 责 任 本 公 司 负 责 人 和 主 管 会 计 工

摘 要 在 這 忙 碌 的 社 會 中, 普 遍 人 們 運 動 時 間 其 實 並 不 充 裕, 體 力 越 來 越 差 的 情 況 下 還 隨 意 飲 食 導 致 身 體 健 康 越 來 越 差, 因 此 本 專 題 打 算 利 用 健 康 飲 食 的 方 式 改 善 這 些 人 的 體 質,

CDWA Mapping. 22 Dublin Core Mapping

Transcription:

1DataSet 1 DataSet DataSetSystem.Data DataSet DataTableDataRelation DataTable DataSet DataSetTyped DataSet DataSet DataSetDataTable DataSetDataTable DataTable 45 DataSet DataSet DataSetTypedUntyped DataSetsDataSet DataTableDataTableDataTable DataSetTablesDataSetSchema DataSetDataTable DataColumnDataSets.xsd CustomersTable Visual StudioDataSet DataSetDataSet DataTable DataRelation DataSetData Source Configuration Wizard Microsoft.NET Framework 2.0 Windows

7 DataSet DataSet TableColumnDataSet DataSet NOTE DataSet DataAdapterDataSetDataAdapter DataSet DataSetDataSetDataSet NorthwindDataSet DataSet Dim NorthwindDataSet As New DataSet ("NorthwindDataSet") DataSet NorthwindDataSet = new DataSet ("NorthwindDataSet"); DataSetDataTable DataSetDataSet DataTableNorthwindDataSet CustomersTableOrdersDataTableDataTable ' DataTable Dim CustomersTable As New DataTable Dim OrdersDataTable As New DataTable ' DataTableDataSetTables NorthwindDataSet.Tables.Add(CustomersTable) NorthwindDataSet.Tables.Add(OrdersDataTable)

1DataSet // DataTable DataTable CustomersTable = new DataTable (); DataTable OrdersDataTable = new DataTable (); // DataTableDataSetTables NorthwindDataSet.Tables.Add(CustomersTable); NorthwindDataSet.Tables.Add(OrdersDataTable); DataSetDataTable DataSetDataTableDataRelation DataTable DataRelation Constructor DataSet Relations NorthwindDataSet CustomersOrdersDataTableCustomerID ' DataRelation Dim CustomersOrders As New DataRelation ("CustomersOrders", _ CustomersTable.Columns("CustomerID"), OrdersTable.Columns("CustomerID")) ' DataSet NorthwindDataSet.Relations.Add(CustomersOrders) // DataRelation DataRelation CustomersOrders = new DataRelation ("CustomersOrders", CustomersTable.Columns["CustomerID"], OrdersTable.Columns["CustomerID"]); // DataSet NorthwindDataSet.Relations.Add(CustomersOrders); Microsoft.NET Framework 2.0 Windows

7 DataTable DataTable DataRowDataRowGetParentRow GetChildRowsGetParentRow DataRowGetChildRows DataRow Order Customer Dim Customer As DataRow = SelectedOrdersRow.GetParentRow("FK_Orders_Customers") DataRow Customer = SelectedOrdersRow.GetParentRow("FK_Orders_Customers"); Customer Order Dim Orders() As DataRow = SelectedCustomersRow.GetChildRows( _ "FK_Orders_Customers") DataRow[] Orders = SelectedCustomersRow.GetChildRows("FK_Orders_Customers"); DataSet DataSetMergeDataSetDataSet DataSet DataSetDataSet DataSet DataSetMergePreserveChanges DataSetTrue DataSet DataSetMerge

1DataSet MissingSchemaActionDataSet DataSetMissingSchemaAction AddDataSetDataSet DataSet AddWithKey DataSet ErrorDataSetDataSet Merge IgnoreDataSetDataSet O l d S a l e s D a t a S e t S a l e s - HistoryDataSetPreserveChangesTrue SalesHistoryDataSet.Merge(OldSalesDataSet, True, MissingSchemaAction.Ignore) SalesHistoryDataSet.Merge(OldSalesDataSet, true, MissingSchemaAction.Ignore); DataSet DataSet DataSet DataSetCopy Dim CopyOfDataSet As New DataSet CopyOfDataSet = OriginalDataSet.Copy DataSet CopyOfDataSet = new DataSet(); CopyOfDataSet = OriginalDataSet.Copy(); Microsoft.NET Framework 2.0 Windows

第7章 離線環境下的資料編輯作業 Lab 建立DataSet物件 在下列的練習裡將分別建立具型別 Typed 與不具型別 Untyped 的 DataSet物件 Exercise 1 利用DataSet設計工具建立DataSet DataSet設計工具是專供設計階段使用的工具 藉由自伺服器總管拖曳資料 庫裡的資料表的方式 來輔助建立具型別的DataSet物件 當資料表被拖曳 至設計工具上時 這些資料表便自動被轉換成DataSet裡具型別的物件 做 為資料存取的程式碼將大幅度地被簡化 1. 首先先建立一個名為DataSetDesignerExample的視窗應用程式 2. 自 專案 功能表裡選擇執行 加入新項目 選項 3. 選擇資料集樣版 並命名為NorthwindDataSet.xsd 4. 自伺服器總管理挑選Customers資料表 並將其拖曳至設計工具上 5. 自伺服器總管理挑選Orders資料表 並將其拖曳至設計工具上 完成拖曳Customers以及Orders資料表至DataSet設計工具上後 此時 的設計工具看起來應接近如圖7-1所示 圖7-1 DataSet設計工具上對應至Customers以及Orders這兩個資料表的 DataTable物件以及TableAdapter物件

1DataSet 6. Build 7. ListBoxForm1Customers- ListBox 8. Form1 o Name = GetCustomersButton o Text = Get Customers 9. Get CustomersGetCustomers- Button_Click ' Northwind DataSet Dim NorthwindDataSet1 As New NorthwindDataSet ' CustomersTableAdapter Dim CustomersTableAdapter1 As New NorthwindDataSetTableAdapters. CustomersTableAdapter ' FillCustomers DataTable CustomersTableAdapter1.Fill(NorthwindDataSet1.Customers) ' CustomersCompanyNameListBox For Each NWCustomer As NorthwindDataSet.CustomersRow In NorthwindDataSet1.Customers.Rows CustomersListBox.Items.Add(NWCustomer.CompanyName) Next // Northwind DataSet NorthwindDataSet NorthwindDataSet1 = new NorthwindDataSet (); // CustomersTableAdapter NorthwindDataSetTableAdapters.CustomersTableAdapter CustomersTableAdapter1 = new NorthwindDataSetTableAdapters.CustomersTableAdapter(); // FillCustomers DataTable CustomersTableAdapter1.Fill(NorthwindDataSet1.Customers); // CustomersCompanyNameListBox foreach (NorthwindDataSet.CustomersRow NWCustomer in NorthwindDataSet1. Microsoft.NET Framework 2.0 Windows

7 Customers.Rows) { CustomersListBox.Items.Add(NWCustomer.CompanyName); } 10.Get Customers CompanyName7-2CustomersListBox 7-2Get CustomersCustomersListBox CompanyName Exercise 2DataSet Data Source Configuration Wizard DataSet 1. DataSourceWizardExample 2. NOTE Data 10

1DataSet 3. 7-3Choose A Data Source Type 7-3 4. 7-4 Choose Your Data Connection Northwind 7-4 Microsoft.NET Framework 2.0 Windows 11

7 5. 7-5 Application Configuration File 7-5 6. 7-6 Customers 7-6 12

1DataSet 7. DataSet Data-bound 8. Form1 9. CustomersForm17-7 7-7CustomersVisual Studio IDEForm1 CustomersVisual Studio Customers DataTable 10. Customers7-8 Microsoft.NET Framework 2.0 Windows 13

第7章 離線環境下的資料編輯作業 圖7-8 顯示於Form1上的Customers資料 Exercise 3 設定不具型別的DataSet物件 自工具箱裡拖曳DataSet物件至表單上 以建立不具型別的DataSet物件 1. 建立一個名為UntypedDataSet的視窗應用程式 2. 自工具箱的資料 Data 區段裡拖曳一個DataSet物件至Form1之上 3. 自 加入資料集 Add DataSet 的對話方塊裡 選擇 不具型別 資料集 並按 確定 4. 拖曳一個DataGridView控制項至表單之上 5. 選取元件匣上的DataSet1執行個體 並切換至屬性視窗上的Tables屬 性 用滑鼠點擊Tables屬性後方的Ellipsis( )按鈕 以開啟 資料表 集合編輯器 Tables Collection Editor 6. 加入一個資料表並將其Name以及TableName屬性設定為Categories 7. 選取Columns屬性並用滑鼠點擊Ellipsis 按鈕 以開啟 資料行 集合編輯器 Columns Collection Editor 8. 加入一個資料行 並做以下設定 o AllowDBNull = False o AutoIncrement = True 14

1DataSet o ColumnName = CategoryID o DataType = System.Int32 o Name = CategoryID 9. o AllowDBNull = False o ColumnName = CategoryName o Name = CategoryName 10. Constraints Unique Constraint 11. CategoryIDPrimary key 12. Constraints Collection Editor 13. o Name = FillDataSetButton o Text = Fill DataSet 14. Form1_Load DataGridView1.DataSource = DataSet1.Tables("Categories") DataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect datagridview1.datasource = DataSet1.Tables["Categories"]; datagridview1.selectionmode = DataGridViewSelectionMode.FullRowSelect; 15. FillDataSetButton_Click Dim newrow As DataRow = DataSet1.Tables("Categories").NewRow() newrow.item("categoryname") = "Beverages" DataSet1.Tables("Categories").Rows.Add(newRow) Dim newrow2 As DataRow = DataSet1.Tables("Categories").NewRow() newrow2.item("categoryname") = "Condiments" Microsoft.NET Framework 2.0 Windows 15

7 DataSet1.Tables("Categories").Rows.Add(newRow2) Dim newrow3 As DataRow = DataSet1.Tables("Categories").NewRow() newrow3.item("categoryname") = "Seafood" DataSet1.Tables("Categories").Rows.Add(newRow3) DataRow newrow = DataSet1.Tables["Categories"].NewRow(); newrow["categoryname"] = "Beverages"; DataSet1.Tables["Categories"].Rows.Add(newRow); DataRow newrow2 = DataSet1.Tables["Categories"].NewRow(); newrow2["categoryname"] = "Condiments"; DataSet1.Tables["Categories"].Rows.Add(newRow2); DataRow newrow3 = DataSet1.Tables["Categories"].NewRow(); newrow3["categoryname"] = "Seafood"; DataSet1.Tables["Categories"].Rows.Add(newRow3); 16. Form1DataSet1 17. Tables DataSet 18. NameTableNameProducts 19. o AllowDBNull = False o AutoIncrement = True o ColumnName = ProductID o DataType = System.Int32 o Name = ProductID 20. o AllowDBNull = False o ColumnName = ProductName o DataType = System.String o Name = ProductName 16

1DataSet 21. o AllowDBNull = False o ColumnName = CategoryID o DataType = System.Int32 o Name = CatID 22. ConstraintsProducts 23. ProductID 24. Foreign Key Constraint o = Categories o = Products o = CategoryID o = CategoryID 25. 26. 27. DataSet1Relations EllipsisDataSet1DataRelation 28. Relations Collection Editor o = CategoriesProducts o = Categories o = Products o = CategoryID o = CategoryID 29. 30. FilllDataSetButton_Click Microsoft.NET Framework 2.0 Windows 17

7 Dim newrow4 As DataRow = DataSet1.Tables("Products").NewRow() newrow4.item("categoryid") = 1 newrow4.item("productname") = "Chai" DataSet1.Tables("Products").Rows.Add(newRow4) Dim newrow5 As DataRow = DataSet1.Tables("Products").NewRow() newrow5.item("categoryid") = 2 newrow5.item("productname") = "Aniseed Syrup" DataSet1.Tables("Products").Rows.Add(newRow5) Dim newrow6 As DataRow = DataSet1.Tables("Products").NewRow() newrow6.item("categoryid") = 3 newrow6.item("productname") = "Ikura" DataSet1.Tables("Products").Rows.Add(newRow6) Dim newrow7 As DataRow = DataSet1.Tables("Products").NewRow() newrow7.item("categoryid") = 1 newrow7.item("productname") = "Chang" DataSet1.Tables("Products").Rows.Add(newRow7) Dim newrow8 As DataRow = DataSet1.Tables("Products").NewRow() newrow8.item("categoryid") = 2 newrow8.item("productname") = "Chef Anton's Gumbo Mix" DataSet1.Tables("Products").Rows.Add(newRow8) Dim newrow9 As DataRow = DataSet1.Tables("Products").NewRow() newrow9.item("categoryid") = 3 newrow9.item("productname") = "Boston Crab Meat" DataSet1.Tables("Products").Rows.Add(newRow9) DataRow newrow4 = DataSet1.Tables["Products"].NewRow(); newrow4["categoryid"] = 1; newrow4["productname"] = "Chai"; DataSet1.Tables["Products"].Rows.Add(newRow4); DataRow newrow5 = DataSet1.Tables["Products"].NewRow(); newrow5["categoryid"] = 2; newrow5["productname"] = "Aniseed Syrup"; DataSet1.Tables["Products"].Rows.Add(newRow5); DataRow newrow6 = DataSet1.Tables["Products"].NewRow(); 18

1DataSet newrow6["categoryid"] = 3; newrow6["productname"] = "Ikura"; DataSet1.Tables["Products"].Rows.Add(newRow6); DataRow newrow7 = DataSet1.Tables["Products"].NewRow(); newrow7["categoryid"] = 1; newrow7["productname"] = "Chang"; DataSet1.Tables["Products"].Rows.Add(newRow7); DataRow newrow8 = DataSet1.Tables["Products"].NewRow(); newrow8["categoryid"] = 2; newrow8["productname"] = "Chef Anton's Gumbo Mix"; DataSet1.Tables["Products"].Rows.Add(newRow8); DataRow newrow9 = DataSet1.Tables["Products"].NewRow(); newrow9["categoryid"] = 3; newrow9["productname"] = "Boston Crab Meat"; DataSet1.Tables["Products"].Rows.Add(newRow9); 31. DataGridView1_CellDoubleClick ' CategoryID Dim Category As Integer = CInt(DataGridView1.SelectedRows(0). Cells("CategoryID").Value) ' DataRow Dim rows() As DataRow = DataSet1.Tables("Categories").Select("CategoryID = " & Category) ' GetChildRows Dim ProductList As String = "" For Each r As DataRow In rows(0).getchildrows("categoriesproducts") ProductList += r.item("productname").tostring & Environment.NewLine Next ' MessageBox.Show(ProductList) // CategoryID int Category = (int)datagridview1.selectedrows[0].cells["categoryid"]. Microsoft.NET Framework 2.0 Windows 19

7 Value; // DataRow DataRow[] rows = DataSet1.Tables["Categories"].Select("CategoryID = " + Category); // GetChildRows string ProductList = ""; foreach (DataRow r in rows[0].getchildrows("categoriesproducts")) { ProductList += r["productname"].tostring() + Environment.NewLine; } // MessageBox.Show(ProductList); 32. Fill DataSet 33. Category Product DataSet DataTableDataRelationDataSet DataSetDataSet Designer Data Source Configuration WizardDataSet DataSetTableAdapter DataSet DataSet DataSet 20

1DataSet 1. DataSet A. Pointer B. DataTableDataRelation C. D. 2. DataSet A. DataTableDataRelationDataAdapter B. DataTableDataColumnDataRelation C. DataTableDataRelationConstraint D. DataTableDataColumnType 3. DataSet A. DataSetGetParentRowGetChildRows B. DataTableGetParentRowGetChildRows C. DataRowGetParentRowGetChildRows D. DataRelationParentColumnsChildColumns NOTE Microsoft.NET Framework 2.0 Windows 21