hmmm DAO !!! 3 question ???
-
Hi :) I have some question about DAO : 1 - When I use MFC wizard there is three choice (Snapshot , Dynaset , Table),so what difference ... 2 - If my access file has two tables I have two problems : A- How I can determine which table I want to add record ... B- When I use code like this m_pSet->AddNew(); m_pSet->m_id=1; //table 1 m_pSet->m_name="Ahmad"; //table 1 m_pSet->m_id2=1; //table 2 m_pSet->m_phone=21598356; //table 2 m_pSet->Update(); a meesage box appeare and tell me that : Can't update. Database or object is read only 3- How I can use SQL statements with VC++ 6 ... Thank you AHMAD ALWASHALI
-
Hi :) I have some question about DAO : 1 - When I use MFC wizard there is three choice (Snapshot , Dynaset , Table),so what difference ... 2 - If my access file has two tables I have two problems : A- How I can determine which table I want to add record ... B- When I use code like this m_pSet->AddNew(); m_pSet->m_id=1; //table 1 m_pSet->m_name="Ahmad"; //table 1 m_pSet->m_id2=1; //table 2 m_pSet->m_phone=21598356; //table 2 m_pSet->Update(); a meesage box appeare and tell me that : Can't update. Database or object is read only 3- How I can use SQL statements with VC++ 6 ... Thank you AHMAD ALWASHALI
Here's some short replies. I really recommend that you read some books on the subject, as it is a huge one. "Microsoft Jet Database Engine Programmers Guide" used to be online on MSDN, but I can't find it there anymore. It's a bit outdated anyway, but gives you a good grip on DAO (although it's written for VB!!!). If you have some MSDN Library CD's from last year I guess it will be there. The answers: 1: snapshot: the resultset is a snapshot of the data in the database. Changes to the data in the db after the snapshot is opened is not reflected in the snapshot. The snapshot is read-only (and I vaguely remember something about it being forward-only also). Dynaset: the resultset represents the actual data in the database at the time you fetch (i.e. read) the data. Updateable. Snapshots and Dynasets are the result of a query, i.e. an SQL statement. Table: as Dynaset, but gives you all the fields of one particular table. Among other things very useful if you want to browse the table, or as a basis for a data-entry form in your program. 2: You probably asked for a snapshot - they're read-only. 3: Use a QueryDef object. Here you can set the SQL text. good luck Steen
-
Here's some short replies. I really recommend that you read some books on the subject, as it is a huge one. "Microsoft Jet Database Engine Programmers Guide" used to be online on MSDN, but I can't find it there anymore. It's a bit outdated anyway, but gives you a good grip on DAO (although it's written for VB!!!). If you have some MSDN Library CD's from last year I guess it will be there. The answers: 1: snapshot: the resultset is a snapshot of the data in the database. Changes to the data in the db after the snapshot is opened is not reflected in the snapshot. The snapshot is read-only (and I vaguely remember something about it being forward-only also). Dynaset: the resultset represents the actual data in the database at the time you fetch (i.e. read) the data. Updateable. Snapshots and Dynasets are the result of a query, i.e. an SQL statement. Table: as Dynaset, but gives you all the fields of one particular table. Among other things very useful if you want to browse the table, or as a basis for a data-entry form in your program. 2: You probably asked for a snapshot - they're read-only. 3: Use a QueryDef object. Here you can set the SQL text. good luck Steen