simongod
asked on
how to save to a database
I can open a database and have its contents displayed inside of a listctrl. When I dblclick on the listctrl the data is displayed in some edit controls. When I click on another listbox more data is entered into another edit control. All the data that is accumulated inside of the edit controls I want to save to the database inside of my listctrl. Please tell me the easiest way to perform this.
ASKER
CDaoRecordset rec;
That is what I have for my recordset. How might I use the update function? To perform the updating. I want it to take the date from the edit control fields (which is the new stuff) and update the database with it. Then the changes should show up in the listctrl that shows the open database fields.
That is what I have for my recordset. How might I use the update function? To perform the updating. I want it to take the date from the edit control fields (which is the new stuff) and update the database with it. Then the changes should show up in the listctrl that shows the open database fields.
ASKER
int nSel = m_database.GetNextItem(-1, LVNI_SELECTED);
if(nSel != LB_ERR)
{
char szName[32];
m_database.GetItemText(nSe l, 0, szName, 32);
int nSelection = m_selectblock.GetCurSel();
CString szSelection;
if(nSelection != LB_ERR)
{
m_selectblock.GetText(nSel ection, szSelection);
m_pblock.SetWindowText(szS election);
}
rec.Edit();
strcpy((char*)covVal.bstrV al, szSelection.GetBuffer(48)) ;
rec.SetFieldValue(_T("Name "), covVal);
rec.Update();
}
Is this what I have. I looked at the parameters for the Update function and I really don't understand them. What do I need to do to make this work?
if(nSel != LB_ERR)
{
char szName[32];
m_database.GetItemText(nSe
int nSelection = m_selectblock.GetCurSel();
CString szSelection;
if(nSelection != LB_ERR)
{
m_selectblock.GetText(nSel
m_pblock.SetWindowText(szS
}
rec.Edit();
strcpy((char*)covVal.bstrV
rec.SetFieldValue(_T("Name
rec.Update();
}
Is this what I have. I looked at the parameters for the Update function and I really don't understand them. What do I need to do to make this work?
ASKER
nope
ASKER
if you want FREE pts answer this question, because I answered figured it out for myself.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks
or better is to
use a CRecordset object have the recordset reflect the new listbox and call Update to update the datasource.
M