CdbDatabase::CreateTableDef Method

Creates a new TableDef object (Microsoft Jet workspaces only).

Syntax

CdbTableDefCreateTableDef(LPCTSTR pstrName=NULL,

LONG lAttributes=-1,

LPCTSTR pstrSource=NULL,

LPCTSTR pstrConnect=NULL);

Parameters

Type Example Description
LPCTSTR pstrName Optional. A pointer to a string that uniquely names the new TableDef object. See the Name property for details on valid TableDef names.
LONG lAttributes Optional. A constant or combination of constants that indicates one or more characteristics of the new TableDef 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 TableDef 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 parts when you use the CreateTableDef method, you can set 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.

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);