I have this function that fills the combobox in C ++ mfc but I do not know how to save the id and the description in the combobox, since it currently does it with the pure description. In c # a pairvalue object is used to do this, but I do not find c ++ mfc. if someone could guide me.
bool CDlgSolicitudes::fObtenerCompradores()
{
CString sConsulta;
bool bRegresa=false;
if( odbc.Open("PostgreSQL", g.server, g.user, g.password , g.database) )
{
sConsulta.Format("select numempleado, nombreempleado from fun_inconsultarcompradores()");
CConsultarCompradores crSQL( &odbc );
if( crSQL.Exec( sConsulta ) )
{
m_cbCompradores.InsertString(-1, "Selecciona un comprador");
crSQL.activarCols();
while( crSQL.Leer() )
{
CString nomComprador;
nomComprador.Format("%s",crSQL.nomComprador);
nomComprador = nomComprador.Trim();
m_cbCompradores.AddString(nomComprador);
}
bRegresa = true;
odbc.Close();
}
else
{
crSQL.odbc->GetLastError(crSQL.GetHstmt());
CString error;
error.Format("[fObtenerCompradores] %s", crSQL.odbc->m_szErrorMsg);
odbc.Close();
AfxMessageBox(error);
}
}
else
{
CString error;
error.Format("[fObtenerCompradores] %s", odbc.m_szErrorMsg);
odbc.Close();
AfxMessageBox(error);
}
return bRegresa;
}
Example: If my function fun_inconsulting buyers () I get the following: 435 - BUYER 1 778 - BUYER 2 921 - BUYER 3
Therefore the combo will fill it with the descriptions: BUYER 1 BUYER 2 BUYER 3
But if I want to save the selected buyer in bd, but nothing else, how can I do it if in the combo I only have the description.