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.
LVL 2
simongodAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mjswartCommented:
You could create an 'INSERT' or an 'UPDATE' sql query which you may then execute with CDatabase::ExecuteSQL

or better is to

use a CRecordset object have the recordset reflect the new listbox and call Update to update the datasource.

M


0
simongodAuthor Commented:
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.
0
simongodAuthor Commented:
int nSel = m_database.GetNextItem(-1, LVNI_SELECTED);
      if(nSel != LB_ERR)
      {
            char szName[32];
            m_database.GetItemText(nSel, 0, szName, 32);
            int nSelection = m_selectblock.GetCurSel();
            CString szSelection;
            if(nSelection != LB_ERR)
            {
                  m_selectblock.GetText(nSelection, szSelection);
                  m_pblock.SetWindowText(szSelection);
            }
            rec.Edit();
            strcpy((char*)covVal.bstrVal, 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?
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

simongodAuthor Commented:
nope
0
simongodAuthor Commented:
if you want FREE pts answer this question, because I answered figured it out for myself.
0
inprasCommented:
Hi simonogod
Why don't U use DB Grid Activex Control I think it suits best for UR needs.
U need not worry about collecting from list and putting in edit control and again from edit control to list control.
Hope this helps
Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
inprasCommented:
Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.