Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fill a combobox with data from my database?

Status
Not open for further replies.

Larree

Programmer
Dec 31, 2002
20
SG
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
 
>> So do I put the code in the WM_InitDialog?

that should work -There are only 10 types of people in the world, those who understand binary and those who don't-

-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top