用代码创建表的代码,在这里记录一下:
static
void
CreateNewTable(Args _args)
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
#AOT
TreeNode treeNode = TreeNode::findNode(#TablesPath);
DictType dictType;
TreeNode treeNodeField;
str tableName = 'Student';
str fieldName1 = 'StudentNum';
str fieldName2 = 'StudentName';
AOTTableFieldList afl;
str property;
![](/Images/OutliningIndicators/InBlock.gif)
void addField(str fieldName,str label,str HelpText,str ExtendedDataTypeName)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
afl.addString(fieldName);
property = strFmt(@"Properties
Label #%1
HelpText #%2
ExtendedDataType #%3
EndProperties
",label,HelpText,ExtendedDataTypeName);
treeNodeField = afl.AOTfindChild(fieldName);
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
treeNodeField.AOTsetProperties(property);
}
;
//Add Table;
treeNode = treeNode.AOTadd(tableName);
![](/Images/OutliningIndicators/InBlock.gif)
//Add Fields
afl = treeNode.AOTfirstChild();
addField(fieldName1,"Student Number","The Number of Student.","AccountNum");
addField(fieldName2,"Student Name","The Name of Student.","AccountName");
![](/Images/OutliningIndicators/InBlock.gif)
//Save
treeNode.AOTcompile(1);
treeNode.AOTsave();
//Restore Extended Data Type's Properties
treeNode.AOTrestore();
![](/Images/OutliningIndicators/InBlock.gif)
//Synchronize Table
appl.dbSynchronize(SysDictTable::newTreeNode(treeNode).id());
![](/Images/OutliningIndicators/InBlock.gif)
}
转载于:https://www.cnblogs.com/Farseer1215/archive/2008/03/13/1104642.html