Hi all,
I am facing a problem. How do u fill a combobox with data from my database? I am looking to fill all the participants name in a race into a combo box. Then when I select the participant's name, all his particulars will also be displayed. I am using dialog for this. So do I put the code in the WM_InitDialog? I got some code from msdn to do this but it is to be input into the OnInitialUpdate function. Will the same code work if I put it in WM_OnInitDialog?
The code is as follows:
// Fill the combo box with all of the courses
CEnrollDoc* pDoc = GetDocument();
pDoc->m_courseSet.m_strSort = "CourseID";
if (!pDoc->m_courseSet.Open())
return;
// Filter, parameterize and sort the CSectionSet recordset
m_pSet->m_strFilter = "CourseID = ?";
m_pSet->m_strCourseIDParam = pDoc->m_courseSet.m_CourseID;
m_pSet->m_strSort = "SectionNo";
m_pSet->m_pDatabase = pDoc->m_courseSet.m_pDatabase;
m_ctlCourseList.ResetContent();
if (pDoc->m_courseSet.IsOpen())
{
while (!pDoc->m_courseSet.IsEOF())
{
m_ctlCourseList.AddString(
pDoc->m_courseSet.m_CourseID);
pDoc->m_courseSet.MoveNext();
}
}
m_ctlCourseList.SetCurSel(0);
Please advice....thanks
I am facing a problem. How do u fill a combobox with data from my database? I am looking to fill all the participants name in a race into a combo box. Then when I select the participant's name, all his particulars will also be displayed. I am using dialog for this. So do I put the code in the WM_InitDialog? I got some code from msdn to do this but it is to be input into the OnInitialUpdate function. Will the same code work if I put it in WM_OnInitDialog?
The code is as follows:
// Fill the combo box with all of the courses
CEnrollDoc* pDoc = GetDocument();
pDoc->m_courseSet.m_strSort = "CourseID";
if (!pDoc->m_courseSet.Open())
return;
// Filter, parameterize and sort the CSectionSet recordset
m_pSet->m_strFilter = "CourseID = ?";
m_pSet->m_strCourseIDParam = pDoc->m_courseSet.m_CourseID;
m_pSet->m_strSort = "SectionNo";
m_pSet->m_pDatabase = pDoc->m_courseSet.m_pDatabase;
m_ctlCourseList.ResetContent();
if (pDoc->m_courseSet.IsOpen())
{
while (!pDoc->m_courseSet.IsEOF())
{
m_ctlCourseList.AddString(
pDoc->m_courseSet.m_CourseID);
pDoc->m_courseSet.MoveNext();
}
}
m_ctlCourseList.SetCurSel(0);
Please advice....thanks