Using Columns in a Table
Last modified: January 09, 2012
Applies to: Windows | Windows Server
A table can be created with an initial set of columns by calling JetCreateTableColumnIndex or without columns by calling JetCreateTable. When the table is created with an initial set of columns in the call to JetCreateTableColumnIndex or JetCreateTableColumnIndex2, it contains a JET_TABLECREATE (or JET_TABLECREATE2) structure. These structures contain an array of JET_COLUMNCREATE structures that define the set of columns in the table. The grbit member sets the options on the column and the coltyp member sets the type of data that can be set in the column.
When the table is created without columns, they must be added by calling JetAddColumn with the JET_COLUMNDEF structure. The grbit member of the JET_COLUMNDEF structure sets the options on the column and the coltyp member sets the type of data that can be set in the column. Default column values are set in the call to JetAddColumn by specifying a value in the pvDefault parameter and the size in the cbDefault parameter. A column without a default value effectively has a default value of NULL.
The values in the table can only be set within the context of a transaction. The transaction begins in the call to JetBeginTransaction and ends in the call to JetCommitTransaction. Inside the transaction, a single column value can be set by calling JetSetColumn, or multiple columns values can be set by calling JetSetColumns. JetSetColumns uses an array of JET_SETCOLUMN structures to set multiple columns in the table. The data is contained in the pvData parameter of JetSetColumn, or the pvData member in JET_SETCOLUMN structure.
The JET_COLUMNBASE, JET_COLUMNLIST, and JET_COLUMNDEF structures are returned in the calls to JetGetTableColumnInfo, and JetGetColumnInfo depending on the type of column that is retrieved. The JET_COLUMNBASE structure describes the parameters of the base column, and the JET_COLUMNLIST contains the information needed to traverse the temporary table that is created by the JetGetColumnInfo and JetGetTableColumnInfo functions.