snoopy22
July 28th, 2003, 02:13 AM
hello guys,
i read the article of "aviad tobally" and he says how to retrieve
data from the database and present it in the Control list.
i've managed to do it with a CString like he did:
void CClientListDlg::RefreshList()
{
COleVariant var; // Start Variables
var.ChangeType(VT_BSTR, NULL);
CString Client,Addr; // End Variables
m_Clients.DeleteAllItems(); // Clear the Control List
db.Open("Clients.mdb"); // Open Clients.MDB
recset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Clients",NULL);
while(!recset.IsEOF()) // Do until EOF
{
int i = 0;
recset.GetFieldValue("Client",var);
Client = (LPCSTR)var.pbstrVal;
m_Clients.InsertItem(i,Client,0);
recset.GetFieldValue("Addr",var);
Addr = (LPCSTR)var.pbstrVal;
m_Clients.SetItemText(0,1,Addr);
i = i++;
recset.MoveNext();
}
recset.Close();
db.Close();
}
but how can i insert "int" types to the control list instead of CString...
thanks in advance!
i read the article of "aviad tobally" and he says how to retrieve
data from the database and present it in the Control list.
i've managed to do it with a CString like he did:
void CClientListDlg::RefreshList()
{
COleVariant var; // Start Variables
var.ChangeType(VT_BSTR, NULL);
CString Client,Addr; // End Variables
m_Clients.DeleteAllItems(); // Clear the Control List
db.Open("Clients.mdb"); // Open Clients.MDB
recset.Open(AFX_DAO_USE_DEFAULT_TYPE,"SELECT * FROM Clients",NULL);
while(!recset.IsEOF()) // Do until EOF
{
int i = 0;
recset.GetFieldValue("Client",var);
Client = (LPCSTR)var.pbstrVal;
m_Clients.InsertItem(i,Client,0);
recset.GetFieldValue("Addr",var);
Addr = (LPCSTR)var.pbstrVal;
m_Clients.SetItemText(0,1,Addr);
i = i++;
recset.MoveNext();
}
recset.Close();
db.Close();
}
but how can i insert "int" types to the control list instead of CString...
thanks in advance!