Creating a table object without database supportIt is possible to create or open a table without database support by passing a session object when creating the table object. Start your session with the CTSESSION_CTREE mode. // create the session and table objects CTSession ASession(CTSESSION_CTREE); CTTable ATable(ASession); // logon to session ASession.Logon(“FAIRCOMS”, “ADMIN”, “ADMIN”); // without database support, it is necessary to // specify the path were the table is located ATable.SetPath(“C:\\MyDocuments”); // open the table try {
ATable.Open(“MyTable”, CTOPEN_NORMAL); } catch (CTException &err) {
printf(“Table open failed with error %d\n, err.GetErrorCode()); } Please note from the code above the need to specify the path where the table is located. If no path is specified, c-treeDB will try to open the table from the current directory. The same principle applies when creating a table without database support: // create the session and table objects CTSession ASession(CTSESSION_CTREE); CTTable ATable(ASession); // logon to session ASession.Logon(“FAIRCOMS”, “ADMIN”, “ADMIN”); // add fields to table ATable.AddField(“Field1”, CT_INT2, 2); ATable.AddField(“Field2”, CT_FSTRING, 30); // without database support, it is necessary to // specify the path were the table is located ATable.SetPath(“C:\\MyDocuments”); // open the table try {
ATable.Create(“MyTable”, CTCREATE_NORMAL); } catch (CTException &err) {
printf(“Create open failed with error %d\n, err.GetErrorCode()); } |
|||