reading and writing raw data to an access database from c++
-
What is the correct way to read and write raw data to and from an access database from c++. The field is a Ole Object in the database. The table has two fields in it 1) type -- long 2) data -- Ole Variant CDaoDatabase db; CDaoRecordset recset(&db); db.Open("data.mdb"); recset.Open(AFX_DAO_USE_DEFAULT_TYPE, "SELECT * FROM Main" ,NULL); recset.AddNew(); recset.SetFieldValue("Type", (long)1); BYTE* pInfo; pInfo = new BYTE [30]; for(int i = 0; i < 30; i++) pInfo[i] = i; recset.Update(); recset.Close(); db.Close(); How do i get the data from pInfo into the the field "data" in the database? this data could be anything from a bitmap to text. thanks
-
What is the correct way to read and write raw data to and from an access database from c++. The field is a Ole Object in the database. The table has two fields in it 1) type -- long 2) data -- Ole Variant CDaoDatabase db; CDaoRecordset recset(&db); db.Open("data.mdb"); recset.Open(AFX_DAO_USE_DEFAULT_TYPE, "SELECT * FROM Main" ,NULL); recset.AddNew(); recset.SetFieldValue("Type", (long)1); BYTE* pInfo; pInfo = new BYTE [30]; for(int i = 0; i < 30; i++) pInfo[i] = i; recset.Update(); recset.Close(); db.Close(); How do i get the data from pInfo into the the field "data" in the database? this data could be anything from a bitmap to text. thanks
Use void SetFieldValue( LPCTSTR lpszName, const COleVariant& varValue ); 1. Put the byte array into a safearray of type VT_U1 2. Embed the array in a variant 3. Pass it to the above function