Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


Connecting A Flex Grid To A Database

We’ll work with databases later in this book, but because flex grids are often used with databases, we’ll take a look at how to connect a database to a flex grid here. To connect a database to a flex grid, follow these steps:

1.  Add a data control, Data1, to your form (the data control is an intrinsic control in Visual Basic and appears in the toolbox when you start Visual Basic).
2.  Set the data control’s DatabaseName property to the database file you want to use. This can also be done at runtime, but if you do so, be sure to call the data control’s Refresh method to update that control. In code, the process goes something like this, where we use the Visual Basic App object’s Path property to get the application’s path (assuming the database file is stored at the same path as the application):
   Data1.DatabaseName = App.Path & "\Nwind.mdb"
     Data1.Refresh
3.  Set Data1’s RecordSource property to the table in the database you want to work with.
4.  Set the flex grid’s DataSource property to the data control’s name, which is Data1 here.

For example, we display the Nwind.mdb database that comes with Visual Basic in a flex grid in Figure 12.18. (There’s a lot more about data-bound controls later in this book; this is just an appetizer.)


Figure 12.18  Opening a database in a flex grid.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.