1 / 9

資料庫程式設計

資料庫程式設計. VB 資料庫設計簡介 週次: 7 建國科技大學 資管系 饒瑞佶. 在 RecordSet 中新增欄位. RecordSet.Fields.Append 欄位名稱 , 資料型態 , 欄位大小 不可以在已經開啟的 RecordSet 中使用 Append 方法 範例 8-1, p.8-3. 階層式 RecordSet. 利用資料表之間的 關聯 來進行(作者 vs. 書籍 資料表) 可以由父 RecordSet 查詢子 RecordSet 的資料 圖 8-3, p.8-8. 階層式 RecordSet 的製作.

yetta
Download Presentation

資料庫程式設計

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. 資料庫程式設計 VB資料庫設計簡介 週次:7 建國科技大學 資管系 饒瑞佶

  2. 在RecordSet中新增欄位 • RecordSet.Fields.Append 欄位名稱, 資料型態,欄位大小 • 不可以在已經開啟的RecordSet中使用Append方法 • 範例8-1, p.8-3

  3. 階層式RecordSet • 利用資料表之間的關聯來進行(作者 vs. 書籍 資料表) • 可以由父RecordSet查詢子RecordSet的資料 • 圖8-3, p.8-8

  4. 階層式RecordSet的製作 • 設定Connection物件的Provider屬性 • cn.Provider=“MS DataShape” • 設定Connection物件的ConnectionString屬性 • cn.ConnectionString=“Dtaa Provider ……..” • 執行Shape Append指令

  5. Shape Append指令 • Shape {父表SQL指令 [[AS] 別名]} • Append({子表SQL指令} [[AS] 別名] • ReLate父表關聯欄位 To子表關聯欄位) • Shape {Select 作者碼,作者名 from 作者} • Append ({Select 作者,書名,分類,售價 from 書籍} AS Authorbook Relate作者名 To 作者)

  6. 如何執行Shape Append指令 • Dim rs as ADODB.Recordset • Dim mysql as String • mysql=“Shape {Select 作者碼,作者名 from 作者} • Append ({Select 作者,書名,分類,售價 from 書籍} AS Authorbook Relate 作者名 To 作者)” • Set rs=NEW ADODB.Recordset • Rs.open mysql,Connection • 將原來的資料表名稱或SQL改成Shape Append指令

  7. 如何取得階層式RecordSet的欄位 • 取得父表欄位內容 • rs.Fields(0) • rs.fields(“作者碼”) • 取得子表 • rs.fields(子表欄位起始編號) • rs.fields(“AuthorBook”) • 取得子表欄位內容 • rs.fileds(“AuthorBook”).Value(0) • rs.fileds(“AuthorBook”).Value(“書名”) • 有點麻煩,所以 ……

  8. 如何取得子表的欄位內容 • 取得子表欄位內容 • rs.fileds(“AuthorBook”).Value(0) • rs.fileds(“AuthorBook”).Value(“書名”) • 有點麻煩,所以 …… • Dim rssub as ADODB.Recordset • Set rssub=New ADODB.Recordset • Set rssub=rs.fileds(“AuthorBook”).Value • 現在可以使用rssub來取得內容 • rssub(“書名”) 範例8-2, 8-3

  9. 補充說明DataGrid與Adodc的用法 • Adodc用法補充 • DataGrid補充說明

More Related