在VC中将获得数据存入数据库ACCESS中的问题,急,高手进!! 有以下几个参量(CString s0,CString s1, CString s2, CString s3, CString s4, CString s5, CString s6........)要传输到数据库ACCESS中,请高手给个例子!要事半功倍一些!!说明以下是用的ODBC,还是ADO.... 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用ado吧,http://www.vckbase.com/document/viewdoc/?id=1215 参考:http://www.programbbs.com/doc/297.htmhttp://www.czxiaofeng.com/bbs/ShowPost.asp?id=474 可以使用DBgrid和remoteData control控件 http://www.vckbase.com/document/viewdoc/?id=496 利用ADO:1、在StdAfx.h中#import "C:\Program Files\Common Files\System\ADO\msado15.dll"\no_namespace rename("EOF", "adoEOF")2、在MainFrm.h中_ConnectionPtr pMyConnect;//创建ADO连接的连接接口_RecordsetPtr pRecordset;3、在MainFrm oncreate中: AfxEnableControlContainer(); AfxOleInit();//初使化COM HRESULT hr=pMyConnect.CreateInstance("ADODB.Connection"); if(FAILED(hr)) return false; _bstr_t strConnect="Provider=Microsoft.Jet.OLEDB.4.0;\Data Source=.\\DataBase\\BKMAN.mdb"; //"Provider=SQLOLEDB;Server=TAO;Database=Forum;uid=sa;pwd=;"; try { pMyConnect->Open(strConnect,"","",adModeUnknown);//打开数据库的 pRecordset.CreateInstance("ADODB.Recordset"); } catch(_com_error &e) { ::MessageBox(NULL,e.Description(),"警告",MB_OK|MB_ICONWARNING); }4、用到的页面extern _ConnectionPtr pMyConnect;//创建ADO连接的连接接口extern _RecordsetPtr pRecordset;下面写数据进库: CString Sqlstr; Sqlstr.Format(_T("Select * from BK_CHANKILL where Kill_Status=0")); pRecordset->Open(_variant_t(Sqlstr),_variant_t((IDispatch *)pMyConnect,true),adOpenStatic,adLockOptimistic,adCmdText); if(!pRecordset->adoEOF) pRecordset->MoveFirst(); CTime time; time = CTime::GetCurrentTime();// Get the current system time CString str_Time; str_Time= time.Format("%Y-%m-%d");// convert the time to the string format pRecordset->PutCollect(_variant_t((long)3),_variant_t((long)1));//把1写进该行第4列,下标0开始 pRecordset->PutCollect(_variant_t((long)7),_variant_t(str_Time)); pRecordset->Update();///保存到库中 pRecordset->Close(); VC的ADO数据库查询与增删改操作实例,看完后你就知道了:http://www.maoyeah.com/display.asp?boardid=3&id=43 利用ADO:_ConnectionPtr cnn;CString sSql;sSql.Format("INSERT INTO 表名 values('%s','%s','%s'),s0,s1,s2);cnn->Execute((_bstr_t)sSql,NULL,adCmdText); 用ADO吧,http://www.vckbase.com上有很多代码可用 获取用USB to IDE 连接的存储设备的设备信息(厂商、序列号什么的) vc6是不是真的太老了??? 本人大三,主要学习C++,今后出来怎么找工作?现在需具备哪些知识? 字体对齐 编译器问题 tab 控件改变背景颜色的问题 在Windows 2000下编译通过的程序,为什么在XP下无法运行? 怎样用VC带的InstallSheild 调用一个 windows Api和启动另一个程序,,谢谢了 怎样才能使一个单文档程序最大化? 谁有清华大学《数据结构》和《编译原理》的听课笔记? 如何识别计算机中安装了什么数据库并获得数据库的安装路径 如何在文档类中设置一个定时器?
http://www.czxiaofeng.com/bbs/ShowPost.asp?id=474
1、在StdAfx.h中#import "C:\Program Files\Common Files\System\ADO\msado15.dll"\
no_namespace rename("EOF", "adoEOF")
2、在MainFrm.h中
_ConnectionPtr pMyConnect;//创建ADO连接的连接接口
_RecordsetPtr pRecordset;
3、在MainFrm oncreate中:
AfxEnableControlContainer();
AfxOleInit();//初使化COM
HRESULT hr=pMyConnect.CreateInstance("ADODB.Connection");
if(FAILED(hr))
return false;
_bstr_t strConnect="Provider=Microsoft.Jet.OLEDB.4.0;\Data Source=.\\DataBase\\BKMAN.mdb";
//"Provider=SQLOLEDB;Server=TAO;Database=Forum;uid=sa;pwd=;";
try
{
pMyConnect->Open(strConnect,"","",adModeUnknown);//打开数据库的
pRecordset.CreateInstance("ADODB.Recordset");
}
catch(_com_error &e)
{
::MessageBox(NULL,e.Description(),"警告",MB_OK|MB_ICONWARNING);
}
4、用到的页面
extern _ConnectionPtr pMyConnect;//创建ADO连接的连接接口
extern _RecordsetPtr pRecordset;下面写数据进库:
CString Sqlstr;
Sqlstr.Format(_T("Select * from BK_CHANKILL where Kill_Status=0"));
pRecordset->Open(_variant_t(Sqlstr),_variant_t((IDispatch *)pMyConnect,true),adOpenStatic,adLockOptimistic,adCmdText);
if(!pRecordset->adoEOF)
pRecordset->MoveFirst(); CTime time;
time = CTime::GetCurrentTime();// Get the current system time
CString str_Time;
str_Time= time.Format("%Y-%m-%d");// convert the time to the string format pRecordset->PutCollect(_variant_t((long)3),_variant_t((long)1));//把1写进该行第4列,下标0开始
pRecordset->PutCollect(_variant_t((long)7),_variant_t(str_Time));
pRecordset->Update();///保存到库中
pRecordset->Close();
_ConnectionPtr cnn;
CString sSql;
sSql.Format("INSERT INTO 表名 values('%s','%s','%s'),s0,s1,s2);
cnn->Execute((_bstr_t)sSql,NULL,adCmdText);