How to Delete a Table from a Database Using Visual BasicLast reviewed: June 21, 1995Article ID: Q110959 |
The information in this article applies to:
- Professional Edition of Microsoft Visual Basic for Windows, version 3.0
SUMMARYThis article describes how to delete a table from a database using the Professional Edition of Visual Basic version 3.0 for Windows. This technique works for any database that is in the native Microsoft Access database format. With slight modifications, it will also work with non-Microsoft Access databases.
MORE INFORMATIONTo delete a table from a Microsoft Access database in Visual Basic, use any of the following methods:
If you want to delete all the records in a table and still preserve the TableDef table definition, you can use the Execute method to do an SQL Delete command. For example:
Dim db as database Set db=OpenDatabase("testing.mdb") db.Execute "Delete From BadTable" Sample Program
The Database Object HierarchyAt the top of the database object hierarchy is the Database object, not to be confused with the Database property of the data control. One of the properties of the Database object is the TableDefs collection, which is also an object. The TableDefs collection represents all the individual TableDef objects associated with the Table objects, including any attached external tables. The TableDef objects each represent the structure or metadata of a table. Each TableDef object consists of properties. For example, the Name property gives you the name of the table. The Fields and Indexes properties of a TableDef object are collections of two additional data access objects, the Field object and the Index object. For more information, see the Visual Basic Help menu.
More Examples of Data AccessThe VISDATA.MAK project, which is installed in the VB3\SAMPLES\VISDATA directory, gives extensive examples of data access. The VISDATA sample program uses every data access function in Visual Basic. Refer to the VISDATA source code for examples that show how to use each data access function.
|
Additional reference words: 3.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |