How to create a database and table with Visualc ++ 6.0

xiaoxiao2021-03-06  83

If you are using Access's .mdb database, you can use CDAODatabase :: Create to create a database, then use CDaotableDef :: Create to create a table, use CDaotableDef :: CreateField to add a table's data field. The CDaotabledef :: CreateField section of VC can find definitions of various fields.

Here is an example of establishing a table:

CDAODATABASE DAODB; TRY {DAODB.Open ("MyServer // MyShare // MYDIR / / MYDB.MDB"); CDaotableDef Table (& DAODB); Table.create ("Students"); Table.createField ("ID", DBINTEGER, 2); table.createfield ("name", dbtext, 10); table.Append ();} catch (cdaoException * e) {afxMessageBox (e-> m_perrorinfo-> m_strdescription); E-> delete (); return false }

转载请注明原文地址:https://www.9cbs.com/read-106336.html

New Post(0)