Simple databse problem
-
Hi! I have a mdb file created by Access 2002 and I am using ado. (and no mfc) pSet is my recordet pointer. I connect and open the database like this:
try{ CREATEiNSTANCE(pDb,Connection); pDb->ConnectionString = L"driver={sql server};SERVER=(local);Database=pubs;" L"UID=sa; PWD=;"; pDb->ConnectionString = constr; pDb->Open( "", "", "", -1 ); CREATEiNSTANCE(pSet,Recordset) pSet->PutRefActiveConnection( pDb ); pSet->Open("SELECT TEST1 FROM TABLE1", constr, adOpenDynamic, adLockBatchOptimistic, -1); pSet->MoveFirst(); } catch(_com_error &e) { ...... }
This works fine until I call MoveLast or MovePrevious. When I call these it gives an abnormal program termination error. On the net I found some information about it and it tells me that MovePrevious and MoveLast will generate and error if there is no support for bookmarks or no support for backward cursors... I think I managed to integrate backward cursors by specifying adOpenDynamic ( right???). How can I integrate bookmarks or check if my database supports bookmarks? :confused: Thank you very much for your future answers! Well... I am a beginner ... -
Hi! I have a mdb file created by Access 2002 and I am using ado. (and no mfc) pSet is my recordet pointer. I connect and open the database like this:
try{ CREATEiNSTANCE(pDb,Connection); pDb->ConnectionString = L"driver={sql server};SERVER=(local);Database=pubs;" L"UID=sa; PWD=;"; pDb->ConnectionString = constr; pDb->Open( "", "", "", -1 ); CREATEiNSTANCE(pSet,Recordset) pSet->PutRefActiveConnection( pDb ); pSet->Open("SELECT TEST1 FROM TABLE1", constr, adOpenDynamic, adLockBatchOptimistic, -1); pSet->MoveFirst(); } catch(_com_error &e) { ...... }
This works fine until I call MoveLast or MovePrevious. When I call these it gives an abnormal program termination error. On the net I found some information about it and it tells me that MovePrevious and MoveLast will generate and error if there is no support for bookmarks or no support for backward cursors... I think I managed to integrate backward cursors by specifying adOpenDynamic ( right???). How can I integrate bookmarks or check if my database supports bookmarks? :confused: Thank you very much for your future answers! Well... I am a beginner ...I use this set of C++ wrapper classes for use with ADO. I use these and I must say they work great! So give em a try... http://www.codeproject.com/database/caaadoclass1.asp