+ -
当前位置:首页 → 问答吧 → 怎样实现数据库的更新?(vs2005+sql2005 数据库:infobase 表:UserInfo(UserNum,UserName,Password,P))

怎样实现数据库的更新?(vs2005+sql2005 数据库:infobase 表:UserInfo(UserNum,UserName,Password,P))

时间:2011-12-20

来源:互联网


AfxOleInit();
_ConnectionPtr PConn(__uuidof(Connection));
_RecordsetPtr PRst(__uuidof(Recordset));

try
{
PConn->Open(SQLLINE,"","",adModeUnknown);

}
catch(_com_error e)
{
AfxMessageBox(e.Description()); //简单错误处理机制

}

CString Tempstr1,Tempstr2,Tempstr3,Tempstr4;

GetDlgItem(IDC_EDIT5)->GetWindowText(Tempstr1);
GetDlgItem(IDC_EDIT2)->GetWindowText(Tempstr2);
GetDlgItem(IDC_EDIT3)->GetWindowText(Tempstr3);
GetDlgItem(IDC_EDIT4)->GetWindowText(Tempstr4);

CString sqlstr = "SELECT * FROM UserInfo Where UserNum = "+Tempstr1;
BSTR bstrsql = sqlstr.AllocSysString();  
try{
PRst->Open(bstrsql,PConn.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
}
catch(_com_error *e)
{
MessageBox(e->ErrorMessage());
}


try
{

//此处如何添加代码?

}
catch(_com_error *e)
{
MessageBox(e->ErrorMessage());
return;
}

PRst->Close();
PRst.Release();
PConn->Close();
PConn.Release();

作者: fengzhileiyi   发布时间: 2011-12-20

帮顶!!!

作者: wllxe   发布时间: 2011-12-20