void CMyDB::CreateDatabase() { CCeDBDatabase db; // 检查数据库是否存在 if(!CCeDBDatabase::Exists(_T("My Database"))) { file://如果数据库不存在,就创建它 db.Create(_T("My Database")); } } |
CCeDBDatabase db; db.Open(_T(″My Database″)); |
CCeDBDatabase db; if (db.Open(_T(″My Database″))) db.Delete(); |
CCeDBDatabase db; db.Open(_T(″My Database″)); db.Close(); |
// Create database const DWORD DB_IDENT_ID = 11111; const WORD PROP_NAME=101,PROP_AGE=102,PROP_GENDER=103; CCeDBDatabase db ; CEOID poid; CCeDBProp dbprops[3] = { CCeDBProp(CCeDBProp::Type_String,PROP_NAME,CCeDBProp::Sort_Ascending), CCeDBProp(CCeDBProp::Type_UShort,PROP_AGE,CCeDBProp::Sort_Descending), CCeDBProp(CCeDBProp::Type_UShort,PROP_GENDER,CCeDBProp::Sort_UnknownFirst) }; if(!(poid = db.Create((_T("My DB"),DB_IDENT_ID,3,dbprops))) return FALSE; if(!db.Open(poid)) return FALSE; // Add records CCeDBRecord rec; CCeDBProp props[3]; props[0] = CCeDBProp(_T("LiMing"),PROP_NAME); props[1] = CCeDBProp((USHORT)20, PROP_AGE); props[2] = CCeDBProp((USHORT)'M',PROP_GENDER); rec.AddProps(props,3); if(!db.AddRecord(&rec)) return FALSE; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |