Accessing CRecordSet through dialog class
-
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??
-
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 wrote: m_passwordSet.Edit() //get error with this line //debug assertion dbcore.cpp line 1620 [...] may i know what's wrong?? What exactly do you want to do at
CLoginDlg::OnBlogin()
? Do you want to retrieve a user/password from the database, edit an existing one, or add a new pair? The call toEdit
doesn't seem to make sense unless you already have a current record. -- jlr http://jlamas.blogspot.com/[^]