Hi, You cann't write directly class into File. You must use Serialization, and serialize each memeber from your class. See the sample below and look into MSDN for more Info. class CPerson : public CObject { public: DECLARE_SERIAL( CPerson ) // empty constructor is necessary CPerson(){}; CString m_name; WORD m_number; void Serialize( CArchive& archive ); // rest of class declaration }; void CPerson::Serialize( CArchive& archive ) { // call base class function first // base class is CObject in this case CObject::Serialize( archive ); // now do the stuff for our specific class if( archive.IsStoring() ) archive << m_name << m_number; else archive >> m_name >> m_number; } a
KalliMan
Posts
-
How to read/write an object of MyClass from/to a file. -
SQLConnect With Custom ODBC DriverDear all, I'm trying to write an ODBC Driver DLL. I register it with SQLInstallDriverEx and Implement "ConfigDSN" and "SQLConnect". With "SQLConfigDataSource" i register Some Data source( ds1 ), but if I try to connect via "SQLConnect" ODBC's "SQLGetDiagRec" return "Driver Doesn't support this function" !?!?. I found my DSN ( ds1 )in ODBC Data sources in Control Panel, and when i open it, ODBC shows an error message "Driver's ConfigDSN : Component not found in registry". But in registry in "ODBCINST" I have "ConnectFunctions=YNN" which mean that I support "ConfigDSN" !?!. The same situation after reinstal MDAC. My DLL's functions work fine if i load dll with "Afx/LoadLibrary". What is Wrong? Win2000 SP3, MDAC 2.8 -------------------- Here is my Driver String which i use to register my Odbc driver: LPCTSTR pszDriver = _T("MyDriver\0DRIVER=MyDriver.dll\0SETUP=MyDriver.dll\0SQLLevel=1\0FileUsage=0\0DriverODBCVer=01\0ConnectFunctions=YNN\0APILevel=2\0CPTimeout=60\0\0"); SQLInstallDriverEx(pszAttributes ,NULL, szLoc, FILENAME_MAX, &nLocLen, ODBC_INSTALL_COMPLETE, &nUsageCount ); -------------------- Here is my sample code for Connection ---------------------- rc = SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv); rc = SQLSetEnvAttr(henv,SQL_ATTR_ODBC_VERSION,(SQLPOINTER)SQL_OV_ODBC3,0); rc = SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc); rc = SQLConnect(hdbc,(SQLCHAR*) "ds1", SQL_NTS, (SQLCHAR*) "", SQL_NTS, (SQLCHAR*) "", SQL_NTS); ---------------------- Regards : KalliMan a
-
snapping windowsfor mouse pos, try with GetCursorPos(LPPOINT); or DWORD pos = GetMessagePos(); CPoint pt(LOWORD(pos), HIWORD(pos)); ScreenToClient(&pt); KalliMan
-
SetFocus for a chosen Edit Control in MFCPerhaps u must set the focus in 'CTestDlg::OnShowWindow()'. KalliMan
-
OLE DB 'IColumnsInfo2' problemHello. I'm writting application which Open an Access database via OLE DB. And I want to receave all column metadata With 'IColumnsInfo2::GetRestrictedColumnInfo(...)' , but I cannot(or don't know how) implement IColumnsInfo2 with 'IColumnsRowset'. i.e. -------------------------------- IColumnsRowset** ppOLEColumnsInfo; IColumnsInfo2** ppOLEColumnsInfo2; ............. HRESULT hr = ppOLEColumnsInfo->QueryInterface(IID_IColumnsInfo2,(void**)ppOLEColumnsInfo2) //and hr == E_NOINTERFACE -------------------------------- ............ If i try to add 'DBPROP_IColumnsInfo2' property while open 'IColumnRrcorset' with 'IOpenRowset::OpenRowset', result is 'DB_S_ERRORSOCCURRED'. i.e. -------------------------------- IOpenRowset** ppOLEOpenRowset; IColumnsRowset** ppOLEColumnsInfo; .......... DBPROPSET dbPropSet[1]; ULONG cDbPropCount = sizeof(dbPropSet)/sizeof DBPROPSET; const ULONG cProperties = 1; DBPROP rgProperties[cProperties]; pPropSet->rgProperties = rgProperties; pPropSet->cProperties = cProperties; pPropSet->guidPropertySet = DBPROPSET_ROWSET; AddProperty(&rgProperties[1] ,DBPROP_IColumnsInfo2,VT_BOOL,VARIANT_TRUE,DBPROPOPTIONS_OPTIONAL);//doesn't work with DBPROPOPTIONS_REQUIRED, too ............ hr = pOLEOpenRowset->OpenRowset(NULL,&dbID,NULL,IID_IColumnsRowset, 1 ,&dbPropSet,(IUnknown **)&pOLEColumnsRowset ); //and hr == DB_S_ERRORSOCCURRED //and dbPropSet.rgProperties.dwStatus == DBPROPSTATUS_NOTSUPPORTED -------------------------------- So, how can i implement Rowset which can implement IDBColumnInfo2 ? thanks at advice: KalliMan a
-
ADO and 'Unhandled exception in <application> (MSDART.DLL) 0xC0000005: Access Violation'I thing, i found my solution. Im my case the problem was, that I'm Using A Global DBManager's classes Variable, from DLL which Load my DB DLL. Immediatly when I make it member in each class where used, the problem DISAPPEAR, Both DLL, are "implicted Linked"(i.e. export classes with (__declspec(dllimport))). Strange, isn't it? P.S. Avrything was Clear. Evrething was Released ... . KalliMan. a
-
ADO and 'Unhandled exception in <application> (MSDART.DLL) 0xC0000005: Access Violation'Hi Steve, Thanks for your advice, but after 3 days search on net I could not find anything which may help me. I found that I'm not the first with this problem, too. see 'http://forums.devshed.com/t36005/s.html'. Same problem, but no answer. I cannot unload "MSDART.dll" before mine, because it's a SYSTEM dll.I have no access. (I get only ACCESS Violation:))) ). I just know its description: "Microsoft Data Access - OLE DB Runtime Routines". bla bla... Has anybody some other Ideas? a
-
ADO and 'Unhandled exception in <application> (MSDART.DLL) 0xC0000005: Access Violation'Hi, I'm trying to create an extension dll that references a database via ADO, using VC 6(SP 5). The problem comes when the application is exited and it prints the following error: 'Unhandled exception in (MSDART.DLL) 0xC0000005: Access Violation' This happened two times. Once when i try to release 'Connection' or 'Recordet', second after my dll's db's class destructor, if i comment Releasing. I was trying with three Mdacs. 2.7,2.7SP1, and 2.8. with 2 OSs. 2k(SP4) and XP(SP1) but none of them resolved my problem. I'm Sure that 'CoUninitialize' wasn't called before releasing, becouse if I call "CoInitialize" ,before releasing, the return value is "S_FALSE", which mean "The COM library is already initialized on this apartment". I'll be glad to see any ideas and pointers. Best Regards: KalliMan. a
-
MSAccess Column Format propertyHi, I 'm Using ADOX from VC(I suppose ADO VB is same that ADO VC) to create tables in Access 2000 and Access 97, containing several columns/fields with the (Yes/No) or(datatime) data type. The format property of these fields is blank and needs to be set to (yes/no) or (format date). I need to make this change by using code and not manually, unfortunatly I can't see any way of accessing the Format property of the field. Is there somebody who know how can I chande Format Property From ADO? Or is there some SQL Statement that can do it? I.e. Something like that: "ALTER TABLE MyTable ALTER COLUMN DataTimeField DataTime (here my format string)" --> ("Medium Date") or ("Long Data") or "ALTER TABLE MyTable ALTER COLUMN YesOrNo YESNO(here my format string)" --> ("Yes/No") or ("True/False") Regards: KalliMan.