How to create/use a database using DAO
Submitted by Date of submission User level
Bulent Ozkir March 26, 2001 Beginner
/* Suppose you want to create an access database test.mdb with current version of access on your machine. */
There are two steps:
1. Include dao headers in your project by using #include
2. Create database using CDaoDatabase class:
CDaoDatabase db ;
CDaoTableDef tableDef(&db) ;
db.Create("d:\test.mdb") ;
tableDef.Create("MyTable") ;
tableDef.CreateField("MyField",dbText,255,dbUpdatableField |
dbVariableField) ;
tableDef.Append() ;
tableDef.Close() ;
db.Execute("INSERT INTO MyTable(MyField) VALUES('test')") ;
db.Close() ;