1 / 8

DAO

DAO. 如果要用 簡單的 幾個字來涵蓋 VB資料庫的所 有功能, 那就只有DAO(Data Access Objects)了, DAO最早出現於微軟的Access資料庫, 後來 被VB3.0版引用, 近來則成為微軟相關產品 (包含VC++, Office系列)存取資料庫的標準. 物件 , 物件類別 , 集合物件. Database 物件類別 DBEngine 物件 Workspaces 集合物件. DBEngine 及Workspace物件.

tabib
Download Presentation

DAO

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DAO 如果要用簡單的幾個字來涵蓋VB資料庫的所 有功能, 那就只有DAO(Data Access Objects)了, DAO最早出現於微軟的Access資料庫, 後來 被VB3.0版引用, 近來則成為微軟相關產品 (包含VC++, Office系列)存取資料庫的標準.

  2. 物件,物件類別,集合物件 Database 物件類別 DBEngine 物件 Workspaces 集合物件

  3. DBEngine及Workspace物件 Set db = DBEngine.Workspace(0).OpenDatabase( … )

  4. Database的五大物件 • TableDef物件 • QueryDef物件 • Recordset物件 • Relation物件 • Container物件

  5. Example for VisualBasic Dim db As Database Dim rs As Recordset Private Sub Form_Load Set db = DBEngine.Workspaces(0).OpenDatabase(App.Path + “\..\mdb\stock.mdb) Set rs = db.OpenRecordset(“股票行情表”) End Sub Private Sub Command_Click() ‘列出Recordset的所有資料錄 Dim S As String rs.MoveFirst List.Clear While Not rs.EOF S = “” For i=0 To rs.Fields.Count - 1 S = S & rs.Fields(i).Value & Chr(vbKeyTab) Next List.AddItem S rs.MoveNext Wend End Sub

  6. 結論 DAO所涵蓋的功能相當龐大, 當不是很清楚一 個DAO物件如和使用時, 除了查閱VB的說明 文件外, 你還可研究VisData的原始程式碼, 它 是一個功能相當齊全的資料庫工具程式, 且 幾乎所有DAO物件的使用範例都可在這個程 式的原始程式碼中找到.

  7. Reference • VB5與資料庫程式設計 王國榮著 1988,5

More Related