使用CRecordset类使用mfc将数据插入数据库 [英] using CRecordset class to insert data into database using mfc

查看:544
本文介绍了使用CRecordset类使用mfc将数据插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,我已经从数据库中检索数据,但是我不知道如何将数据插入数据库中.


Here is my code,I have retrieved the data from the database but i don''t know how to insert the data into the database.


// TODO: Add your control notification handler code here

	CDatabase cd;	

	if(cd.OpenEx ("DSN=SampleData",0 ))
		MessageBox("connected");
	
	if(cd.BeginTrans ())
		MessageBox("BeginTrans");

	CRecordset rd(&cd);
	if(rd.Open (CRecordset::dynaset, _T("Select * from Sample")))
		MessageBox ("recordset opened");
	
	CString str;	
	rd.GetFieldValue("Name",str);      // Data retrived from the database.....
	MessageBox(str);
	rd.Close ();
	cd.Close ();

推荐答案

例如,参见

这篇关于使用CRecordset类使用mfc将数据插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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