Creates a new CdbTableDef object (Microsoft Jet workspaces only).
Syntax
CdbTableDefCreateTableDef(LPCTSTR pstrName = NULL,
LONG lAttributes = -1,
LPCTSTR pstrSource = NULL,
LPCTSTR pstrConnect = NULL);
Parameters
Type | Argument | Description |
LPCTSTR | pstrName | Optional. A pointer to a string that uniquely names the new CdbTableDef object. See the Name property for details on valid CdbTableDef names. |
LONG | lAttributes | Optional. A constant or combination of constants that indicates one or more characteristics of the new CdbTableDef object. See the Attributes property for more information. |
LPCTSTR | pstrSource | Optional. A pointer to a string containing the name of a table in an external database that is the original source of the data. The source string becomes the SourceTableName property setting of the new CdbTableDef object. |
LPCTSTR | pstrConnect | Optional. A pointer to a string containing information about the source of an open database, a database used in a pass-through query, or a linked table. See the Connect property for more information about valid connection strings. |
Remarks
If you omit one or more of the optional arguments when you use the CreateTableDef method, you can use an appropriate assignment statement to set or reset the corresponding property before you append the new object to a collection. After you append the object, you can alter some but not all of its properties. See the individual property topics for more details.
If pstrName refers to an object that is already a member of the collection, or you specify an invalid property in the CdbTableDef or CdbField object you're appending, a run-time error occurs when you use the Append method. Also, you can't append a CdbTableDef object to the TableDefs collection until you define at least one CdbField for the CdbTableDef object.
To remove a CdbTableDef object from the TableDefs collection, use the Delete method on the collection.
Usage
#include <afxole.h>
#include <dbdao.h>
// Create a new TableDef object in the Biblio.mdb database.
CdbDbenine dben;
CdbTableDef tdfTitle;
CdbField fldComments;
CdbDatabase dbsBiblio;
dbsBiblio = dben.Workspaces[0L].OpenDatabase(_T("Biblio.mdb"));
// Create new TableDef.
tdfTitle = dbsBiblio.CreateTableDef(_T("Title Detail"));
// Create and append field to tdfTitle.
fldComments = tdfTitle.CreateField(_T("Comments"), dbMemo);
tdfTitle.Fields.Append(fldComments);
// Append TableDef to TableDefs collection.
dbsBiblio.TableDefs.Append(tdfTitle);