43
存存 存存 Access Access 存存存 存存存 DataGridview DataGridview 存存 存存

存取 Access 資料庫 用 DataGridview 顯示

Embed Size (px)

DESCRIPTION

存取 Access 資料庫 用 DataGridview 顯示. Connection + Command + DataReader. 方法一:直接設定物件. 設定DataGridView物件 自動產生程式碼 完成資料連結與顯示工作. 步驟一:建立新專案. 步驟二:設計 UI. 兩個 DataGridView + ㄧ個 Button 物件. 步驟三:設定 GridView1. 步驟四:設定資料來源. 步驟五:選擇資料連接引擎. 步驟六:查看連接字串. 步驟七:儲存連接字串. 步驟八:選擇要使用的 Table 與 field. 設定完成畫面. 執行結果. - PowerPoint PPT Presentation

Citation preview

Page 1: 存取 Access 資料庫 用 DataGridview 顯示

存取存取 AccessAccess 資料庫資料庫用用 DataGridviewDataGridview 顯示顯示

Page 2: 存取 Access 資料庫 用 DataGridview 顯示

Connection + Command + Connection + Command + DataReaderDataReader

Page 3: 存取 Access 資料庫 用 DataGridview 顯示

方法一:直接設定物件方法一:直接設定物件

設定設定 DataGridViewDataGridView 物件物件自動產生程式碼自動產生程式碼完成資料連結與顯示工作完成資料連結與顯示工作

設定設定 DataGridViewDataGridView 物件物件自動產生程式碼自動產生程式碼完成資料連結與顯示工作完成資料連結與顯示工作

Page 4: 存取 Access 資料庫 用 DataGridview 顯示

步驟一:建立新專案步驟一:建立新專案

Page 5: 存取 Access 資料庫 用 DataGridview 顯示

步驟二:設計步驟二:設計 UIUI

兩個 DataGridView + ㄧ個 Button 物件

Page 6: 存取 Access 資料庫 用 DataGridview 顯示

步驟三:設定步驟三:設定 GridView1GridView1

Page 7: 存取 Access 資料庫 用 DataGridview 顯示

步驟四:設定資料來源步驟四:設定資料來源

Page 8: 存取 Access 資料庫 用 DataGridview 顯示

步驟五:選擇資料連接引擎步驟五:選擇資料連接引擎

Page 9: 存取 Access 資料庫 用 DataGridview 顯示

步驟六:查看連接字串步驟六:查看連接字串

Page 10: 存取 Access 資料庫 用 DataGridview 顯示

步驟七:儲存連接字串步驟七:儲存連接字串

Page 11: 存取 Access 資料庫 用 DataGridview 顯示

步驟八:選擇要使用的步驟八:選擇要使用的 TableTable 與與fieldfield

Page 12: 存取 Access 資料庫 用 DataGridview 顯示

設定完成畫面設定完成畫面

Page 13: 存取 Access 資料庫 用 DataGridview 顯示

執行結果執行結果

Page 14: 存取 Access 資料庫 用 DataGridview 顯示

資料移動與顯示資料移動與顯示

加入 Button 與 TextBox

Page 15: 存取 Access 資料庫 用 DataGridview 顯示

資料移動與顯示資料移動與顯示

透過 BindingSource 來移動

Page 16: 存取 Access 資料庫 用 DataGridview 顯示

資料移動與顯示資料移動與顯示

Page 17: 存取 Access 資料庫 用 DataGridview 顯示

方法二:撰寫程式碼方法二:撰寫程式碼

設定設定 CONNECTIONCONNECTION 物件物件設定設定 COMMANDCOMMAND 物件物件設定設定 DATAREADERDATAREADER 物件物件 (( 唯讀唯讀 ))將將 DATAREADERDATAREADER 中資料顯示到中資料顯示到 DATDAT

AGRIDVIEWAGRIDVIEW

設定設定 CONNECTIONCONNECTION 物件物件設定設定 COMMANDCOMMAND 物件物件設定設定 DATAREADERDATAREADER 物件物件 (( 唯讀唯讀 ))將將 DATAREADERDATAREADER 中資料顯示到中資料顯示到 DATDAT

AGRIDVIEWAGRIDVIEW

Page 18: 存取 Access 資料庫 用 DataGridview 顯示

步驟一:引用名稱空間步驟一:引用名稱空間

Page 19: 存取 Access 資料庫 用 DataGridview 顯示

步驟二:連接步驟二:連接 mdbmdb 資料庫資料庫

Page 20: 存取 Access 資料庫 用 DataGridview 顯示

步驟三:連接資料表步驟三:連接資料表

Page 21: 存取 Access 資料庫 用 DataGridview 顯示

步驟四:顯示資料到步驟四:顯示資料到 DataGridViewDataGridView

Page 22: 存取 Access 資料庫 用 DataGridview 顯示

步驟五:關閉連線步驟五:關閉連線

Page 23: 存取 Access 資料庫 用 DataGridview 顯示

Connection + Command + Connection + Command + DataAdapter + DataSetDataAdapter + DataSet

Page 24: 存取 Access 資料庫 用 DataGridview 顯示

步驟一:設計步驟一:設計 UIUI

一個 DataGridView 與 Button

Page 25: 存取 Access 資料庫 用 DataGridview 顯示

步驟二:引用名稱空間步驟二:引用名稱空間

Page 26: 存取 Access 資料庫 用 DataGridview 顯示

步驟二:連接資料庫步驟二:連接資料庫

Page 27: 存取 Access 資料庫 用 DataGridview 顯示

步驟三:連接資料表步驟三:連接資料表

Page 28: 存取 Access 資料庫 用 DataGridview 顯示

執行結果執行結果

Page 29: 存取 Access 資料庫 用 DataGridview 顯示

上下筆資料錄移動上下筆資料錄移動

加入 Button 與 BindingSource

Page 30: 存取 Access 資料庫 用 DataGridview 顯示

上下筆資料錄移動上下筆資料錄移動

異動程式

下ㄧ筆

Page 31: 存取 Access 資料庫 用 DataGridview 顯示

用用 labellabel 顯示資料顯示資料

加入 Panel 與 Label

Page 32: 存取 Access 資料庫 用 DataGridview 顯示

用用 labellabel 顯示資料顯示資料

Page 33: 存取 Access 資料庫 用 DataGridview 顯示

Connection + Command + Connection + Command + DataAdapter + DataSetDataAdapter + DataSet

新增資料新增資料

Page 34: 存取 Access 資料庫 用 DataGridview 顯示
Page 35: 存取 Access 資料庫 用 DataGridview 顯示

讀取讀取 AccessAccess 位置問題位置問題程式目錄程式目錄

bin\debugbin\debug 目錄目錄

Page 36: 存取 Access 資料庫 用 DataGridview 顯示

避免讀取問題

Page 37: 存取 Access 資料庫 用 DataGridview 顯示

新增資料

Page 38: 存取 Access 資料庫 用 DataGridview 顯示

Connection + Command + Connection + Command + DataAdapter + DataSetDataAdapter + DataSet

刪除資料刪除資料

Page 39: 存取 Access 資料庫 用 DataGridview 顯示
Page 40: 存取 Access 資料庫 用 DataGridview 顯示

Connection + Command + Connection + Command + DataAdapter + DataSetDataAdapter + DataSet

修改資料修改資料

Page 41: 存取 Access 資料庫 用 DataGridview 顯示
Page 42: 存取 Access 資料庫 用 DataGridview 顯示

Connection + Command + Connection + Command + DataAdapter + DataSetDataAdapter + DataSet

搜尋資料搜尋資料

Page 43: 存取 Access 資料庫 用 DataGridview 顯示