bool CAdoRWAccess::ModifyData(int p_id,CString p_news,CString p_newsData,CString p_newsTime)
{
CString strSql;
strSql.Format("SELECT * FROM news WHERE ID = %d",p_id);
if(QueryAccess(strSql)==TRUE)
{
// 修改当前记录的字段值
try
{
//得到现在的时间
SYSTEMTIME curTime;
GetLocalTime( &curTime );
int y=curTime.wYear;
int m=curTime.wMonth ;
int d=curTime.wDay ;
NowTime.Format("%d-%02d-%02d",y,m,d); m_pRecordset->PutCollect("news", _variant_t(p_news)); //出错了,为什么???
m_pRecordset->PutCollect("newsData", _variant_t(p_newsData));
m_pRecordset->PutCollect("newsTime",_variant_t(p_newsTime));
m_pRecordset->Update();
return true;
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
return false;
} }
return false;
}其中字段 news newsData 是 备注类型
newsTime 是时间日期类型
我用的是ACCESS数据库
请问,为什么不能修改???
时间备注类型在vc中怎么转换??:)
谢
{
CString strSql;
strSql.Format("SELECT * FROM news WHERE ID = %d",p_id);
if(QueryAccess(strSql)==TRUE)
{
// 修改当前记录的字段值
try
{
//得到现在的时间
SYSTEMTIME curTime;
GetLocalTime( &curTime );
int y=curTime.wYear;
int m=curTime.wMonth ;
int d=curTime.wDay ;
NowTime.Format("%d-%02d-%02d",y,m,d); m_pRecordset->PutCollect("news", _variant_t(p_news)); //出错了,为什么???
m_pRecordset->PutCollect("newsData", _variant_t(p_newsData));
m_pRecordset->PutCollect("newsTime",_variant_t(p_newsTime));
m_pRecordset->Update();
return true;
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
return false;
} }
return false;
}其中字段 news newsData 是 备注类型
newsTime 是时间日期类型
我用的是ACCESS数据库
请问,为什么不能修改???
时间备注类型在vc中怎么转换??:)
谢
m_pRecordSet->AddNew();
备注字段如果不很长,可以用CString型,长的话,需要用char*
COleDateTime oletime(2004, 12, 15, 00, 00, 02);m_pRs->PutCollect("ID",_variant_t("01"));
m_pRs->PutCollect("NAME",_variant_t("tabby"));
m_pRs->PutCollect("PASSWORD",_variant_t("tabby01"));
m_pRs->PutCollect("JOINTIME",_variant_t(oletime));
m_pRs->Update();