List 7-12 FormCustomerフォームのRefreshDataプロシージャ


  1: Private g_objRec As ADODB.Recordset
  2: 
  3: Private Sub RefreshData()
  4:     ' データグリッドに表示されているデータを最新の情報にする
  5:     Dim objCustomer As Business.Customer
  6:     
  7:     ' データベースに接続して,最新の情報を取得し,
  8:     ' データグリッドに表示する
  9:     On Error GoTo ErrHandle
 10:     
 11:     Set objCustomer = CreateObject("Business.Customer")
 12:     Set g_objRec = objCustomer.GetCustomers()
 13:     
 14:     Set DGrid_Customer.DataSource = g_objRec
 15:     
 16:     DGrid_Customer.Refresh
 17:     
 18:     Set objCustomer = Nothing
 19:     
 20:     Exit Sub
 21: 
 22: ErrHandle:
 23:     ' ビジネスオブジェクトの呼び出しに失敗
 24:     MsgBox Err.Description, vbOKOnly, "サーバーとの接続に失敗"
 25:     Set objCustomer = Nothing
 26:     Set g_objRec = Nothing
 27: End Sub