i want to create a login dialog box with username and password details stored in MS Access file. i created a new CRecordSet class : class CPasswordSet : public CRecordset { public: CPasswordSet(CDatabase* pDatabase = NULL); DECLARE_DYNAMIC(CPasswordSet) // Field/Param Data //{{AFX_FIELD(CPasswordSet, CRecordset) long m_ID; CString m_Username; CString m_Password; //}}AFX_FIELD // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CPasswordSet) public: virtual CString GetDefaultConnect(); // Default connection string virtual CString GetDefaultSQL(); // Default SQL for Recordset virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support //}}AFX_VIRTUAL // Implementation #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; and a CDialog class as below with a CPasswordSet public variable m_passwordSet: void CLoginDlg::OnBlogin() { CString str; str = m_passwordSet.m_Username; MessageBox (str); //i get nothing, empty string m_passwordSet.Edit() //get error with this line //debug assertion dbcore.cpp line 1620 } may i know what's wrong??
heavenode
Posts
-
Accessing CRecordSet through dialog class -
Class wizard problemthanks, i found out the problem, it lies inside the constructor. the problem is solved after i removed the 'if section' code. does it mean i cant have an if statement inside constructor??? CTAMADlg::CTAMADlg(CWnd* pParent /*=NULL*/) : CDialog(CTAMADlg::IDD, pParent) { //{{AFX_DATA_INIT(CTAMADlg) m_hDevice = INVALID_HANDLE_VALUE; m_hClose = INVALID_HANDLE_VALUE; m_hClose = CreateEvent (NULL, TRUE, FALSE, NULL); if ( m_hClose == INVALID_HANDLE_VALUE ) { MessageBox("Thread event error!","Error",MB_OK); } //}}AFX_DATA_INIT m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); }
-
Class wizard problemI have problem opening the class wizard, as it will show an error message. After clicking ok, i wont be able to add function, variable etc. from the class wizard. error msg: Parsing error: Expected "=" Input Line: "if (m_hCloas == INVALID HANDLE VALUE)" Anyone knows what has gone wrong?
-
Problem with serializationProblem solved, there's nothing wrong with the code. actually i have another similar application, it's because the save-filetype (fdb) for both applications are the same, so when i save using the second application, the window uses my first application to open and resulting in 'unexpected file format'.
-
Problem with serializationI'm writing a simple flat file database MFC SDI application. However after i save n close the file, i cant open it again and shows 'unexpected file format'. below is my serialize funcation for the new class, the sequence is correct. What other problem can it be? void CPerson::Serialize(CArchive &ar) { CObject::Serialize(ar); if (ar.IsStoring()) ar << m_sName << m_sRoom << m_iSex << m_iStatus; else ar >> m_sName >> m_sRoom >> m_iSex >> m_iStatus; }