Hi,
I have tried to look through as many existing messages on these news-group
to find an answer to my problem, but as I came up blank I have a problem
which I hope someone can help me with. I need to create a new database
(.mdb) file from within an MFC app and set up the tables, and am trying to
use DAO to do this. I have trawled both the VC++ books, etc. and the MSDN
CD to find an answer. I am rather suprised that more people would not want
to do this, and that there was no example on either the VC++ CD or MSDN.
I am using VC 4.2 and NT 4 - I also have MS-Office 95 installed (including
the Access application). Below is a sample of the code I have written,
which is failing:
CDaoDatabase *pDB;
CDaoTableDef *pRootTable;
CDaoRecordset *pExistingRecords;
CDaoTableDefInfo tdiInfo;
pDB = new CDaoDatabase;
pDB->Create("D:\\MYDB.MDB"); // I have made sure that this file does
not exist before running
// create a table def for the root table and try to open it
pRootTable = new CDaoTableDef(pDB);
// create a new table as we can't find an existing one
pRootTable->Create("Test");
pRootTable->SetName("Test"); // I have tried with and without this line
// !!!!!! This next list causes an exception. It is an unknown
exception (error: 0x80000003)
pRootTable->Append(); // ERROR ON THIS LINE
// create the required fields
pRootTable->CreateField("Index", dbInteger, 0, dbAutoIncrField);
pRootTable->CreateField("GroupName", dbText, 16);
pRootTable->CreateField("GroupType", dbByte, 0);
pRootTable->CreateField("GroupUnits", dbText, 16);
pRootTable->Close();
pDB->Close();
delete pRootTable;
delete pDB;
I have tried to get to the bottom of this using the de*, but obviously
can't trace into the OLE automation call to the JET code. All I know is
that the call to Append() caused an exception. Does anyone have any ideas
as to the problem here ? Any help really would be appreciated.
Thanks,
Simon.
--
Simon Culverhouse
Senior Software Engineer
Instron Ltd.
-- My opinions do not necessarily
reflect those of my kind and friendly
employer (so there !) *8) --