TrimTrom
July 24th, 1999, 12:56 PM
Hello,
I am a beginner VC++ 6.0 professional programmer using Win98.
I have the following problem:
I am trying to use dialog data exchange (DDX) with a dialog box in my
application, in order to retrieve data from a database table, edit it,
and then save it. I am however having problems.
I have created a dialogbox resource, and associated it with a CDialog
class in ClassWizard. In the Foreigh Class box I have selected a
CDAORecordset class I had created previously. In the Foreign Variable
box I put the name "m_pSet". I then created member variables for all my
edit boxes in the dialog, selecting fields from the dropdown in the
Member Variable section of ClassWizard.
After this, the ClassWizard generated the following method in my CDialog
class:
void CRView3::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRView3)
DDX_Control(pDX, IDOK, m_OK);
DDX_Control(pDX, IDCANCEL, m_Cancel);
DDX_FieldText(pDX, IDC_EDIT1, m_pSet->m_DisplayName, m_pSet);
DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_Email, m_pSet);
//}}AFX_DATA_MAP
}
It also initialised m_pSet to NULL in the CDialog constructor. But it
did no more than that.
My first problem is that ClassWizard created no code actually to open my
recordset class. So I did that as follows:
void CRView3::GetRecordset()
{
m_pSet = new CAddrRset1(NULL);
m_pSet->Open();
}
After the above measures the dialog box worked OK in that it presented
me with the right data. However, it won't save any changes I make back
to the database. This is my second problem. I thought that all this
was taken care of by dialog data exchange.
I would be very grateful for code showing how to set up dialog data
exchange so that it works properly and saves changes back to the
database.
Thanks,
TrimTrom
----------------------------------
Email: paul.trimming_nospam@dial.pipex.com
Surrey, England
----------------------------------
I am a beginner VC++ 6.0 professional programmer using Win98.
I have the following problem:
I am trying to use dialog data exchange (DDX) with a dialog box in my
application, in order to retrieve data from a database table, edit it,
and then save it. I am however having problems.
I have created a dialogbox resource, and associated it with a CDialog
class in ClassWizard. In the Foreigh Class box I have selected a
CDAORecordset class I had created previously. In the Foreign Variable
box I put the name "m_pSet". I then created member variables for all my
edit boxes in the dialog, selecting fields from the dropdown in the
Member Variable section of ClassWizard.
After this, the ClassWizard generated the following method in my CDialog
class:
void CRView3::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRView3)
DDX_Control(pDX, IDOK, m_OK);
DDX_Control(pDX, IDCANCEL, m_Cancel);
DDX_FieldText(pDX, IDC_EDIT1, m_pSet->m_DisplayName, m_pSet);
DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_Email, m_pSet);
//}}AFX_DATA_MAP
}
It also initialised m_pSet to NULL in the CDialog constructor. But it
did no more than that.
My first problem is that ClassWizard created no code actually to open my
recordset class. So I did that as follows:
void CRView3::GetRecordset()
{
m_pSet = new CAddrRset1(NULL);
m_pSet->Open();
}
After the above measures the dialog box worked OK in that it presented
me with the right data. However, it won't save any changes I make back
to the database. This is my second problem. I thought that all this
was taken care of by dialog data exchange.
I would be very grateful for code showing how to set up dialog data
exchange so that it works properly and saves changes back to the
database.
Thanks,
TrimTrom
----------------------------------
Email: paul.trimming_nospam@dial.pipex.com
Surrey, England
----------------------------------