如何将ListControl中的数据读入CRecordset? [英] How do I read data from a ListControl into a CRecordset?

查看:114
本文介绍了如何将ListControl中的数据读入CRecordset?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个已经存在的旧产品。因此,我必须使用visual studio 2005和C ++ MFC。



现在,我的情况是:



我使用afxdb.h中的函数从Oracle DB中读取一些数据。该数据存储在CRecordset中。我通过将CRecordset传递回填充函数来填充List控件。以上功能正常工作。



现在,我还自定义了列表控件,以便弹出一个小文本框,用于创建'in的效果-place'由用户编辑单元格值。无论如何,一旦编辑完成,列表控件的所有正确单元格都会更新,一切正常。



我想知道的是下一步。我想将列表控件中的当前(已修改的)数据读回到CRecordset,并将此CRecordset返回/传递回调用者模块。调用者模块使用此CRecordset来更新数据库以及执行一些XML编写。



但是如何从列表控件INTO读取CRecordset ???

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???

推荐答案

它是你的个人工作是写那段代码。使用 GetItemText 功能,您可以获得列表控件中的文本,而不是需要使其可用你的数据。



看看 MFC网格控制来自伟大的Chris Maunder(本网站的创始人)。 :-O
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


感谢您的回复。我可以从List控件中读取。我的疑问是,如何将数据插入CRecordset ???

我使用CRecordset的唯一方法如下:



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:

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();
}





现在,当我从列表控件中读取时,我没有M_Database的东西。它只是一个CRecordset和一个List控件。

我也没有SQL查询。



我可以从列表控件中读取数据:





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:

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





甚至循环遍历列表控件的所有项目并读取数据。

我接下来要做什么?

如何创建这里有一个新的CRecordset并插入M_cSelectedUser(在读取所选行的情况下)或M_cAllUsers(如果我正在读取整个列表)

进入CRECORDSET ???



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???

这篇关于如何将ListControl中的数据读入CRecordset?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆