Click here to Skip to main content
15,896,457 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on an already existing old product.Hence, I have to use visual studio 2005 and C++ MFC.

Now, my situation is this:

I read some data from a Oracle DB using functions from afxdb.h. This data is stored into a CRecordset. I populate a List control using the CRecordset by passing it back to a populate function. This above function is working correctly.

Now, I have also customized the list control so that it pops up a small textbox which is used to create an effect of 'in-place' editing of the cell values by the user. Anyway, once the edits are over, all the proper cells of the list control are updated and everything is OK.

What I want to know is the next step. I would like to read back the current (the modified) data from the list control into a CRecordset and return/pass this CRecordset back to the caller module. The caller module uses this CRecordset to update the database as well as to do some XML writing.

But how do I read from a list control INTO a CRecordset???
Posted

It is your personal job to write that code. With the GetItemText function you get the text in the list control and than you need to make it available to your data.

Take alos a look at the code of the MFC Grid control from the great Chris Maunder (Founder of this website). :-O
 
Share this answer
 
Thanks for the reply. I can read from the List control. My doubt is, how do I insert that data into a CRecordset???
The only way I have used a CRecordset is like below:

C++
CRecordset rs(&M_Database);
M_Recordset.Open( CRecordset::forwardOnly, strSQL);
while( !M_Recordset.IsEOF() )
{
	M_Recordset.GetFieldValue( (short)0, result );
	// Do something with the value you got in result
	M_Recordset.MoveNext();
}


Now, when I am reading from the list control, I do not have a M_Database thing with me. Its just a CRecordset and a List control.
Nor do I have a SQL query.

I can read data from the list control with something like this:

C++
int row = listCtrlUser.GetSelectionMark();
if(row < 0)
{
	return;
}
M_cSelectedUser = listCtrlUser.GetItemText(row, 0);


or even loop over all the items of the list control and read the data.
What do I do next though?
How do I create a new CRecordset here and insert the M_cSelectedUser (in case of reading the selected line) OR M_cAllUsers (in case i am reading the whole list)
INTO THE CRECORDSET???
 
Share this answer
 
Comments
barneyman 19-Aug-15 22:08pm    
reply to karsten's comment, or he won't be notified - you've added a new solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900