_ConnectionPtr m_pConnection;
_RecordsetPtr pRstD(__uuidof(Recordset));
_RecordsetPtr pRst(__uuidof(Recordset));
HRESULT hr;
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");
if(SUCCEEDED(hr))
{
hr=m_pConnection->Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=noshery","","",adModeUnknown);
}
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("连接数据库失败\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);
}
int num=1;
CString sSQL;
sSQL.Format("update from 订单表 set 订单状态=%d where 订单号=%d",num,num);
pRst=m_pConnection->Execute((_bstr_t)sSQL,NULL,adCmdText);
_RecordsetPtr pRstD(__uuidof(Recordset));
_RecordsetPtr pRst(__uuidof(Recordset));
HRESULT hr;
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");
if(SUCCEEDED(hr))
{
hr=m_pConnection->Open("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=noshery","","",adModeUnknown);
}
}
catch(_com_error e)
{
CString errormessage;
errormessage.Format("连接数据库失败\r\n错误信息:%s",e.ErrorMessage());
AfxMessageBox(errormessage);
}
int num=1;
CString sSQL;
sSQL.Format("update from 订单表 set 订单状态=%d where 订单号=%d",num,num);
pRst=m_pConnection->Execute((_bstr_t)sSQL,NULL,adCmdText);
解决方案 »
- PKCS#11 接口标准对多线程安全又要求吗?
- VC 如何设置某个快捷方式文件的(.lnk)的指定打开的程序?
- 如何在主窗口下新建几个窗口,而这几个窗口可以相互切换?
- 怎么在一个mfc的对话框程序上添加 工具条和菜单栏
- 关于自动填写网页中的编辑框
- 大家成天说的接口 接口程序 库……都是什么意思啊?怎么实现的都是?
- 今天买了台asus L4000的笔记本电脑,晚上烤机器,散分.
- 一段显示位图的代码,可就是显示不出来!为什么?help me!!!定送分!
- 菜鸟求问:
- 如何在VIEW中对MAINFRAME中的函数进行调用?!
- 关于VC++技术内幕5.0和VC++技术内幕6.0
- 进程调度加入阻塞,唤醒之后的错误,高手帮看一下
HRESULT hr;
//使用记录集来添加记录
_RecordsetPtr Record;
Record.CreateInstance(__uuidof(Recordset));
try
{
hr=Record->Open(sql,
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if((Record->BOF)&&(Record->adoEOF))
{
Record->Close();
Record=NULL;
return;
}
else{
try{
//写入每个字段
Record->PutCollect("UserName",_variant_t(m_name));
Record->PutCollect("ConnectWay",_variant_t(m_connection));
Record->PutCollect("Re",_variant_t(m_re));
Record->Update();
}
catch(...){
Record->Close();
Record=NULL;
AfxMessageBox("修改失败!");
return;
}
}
}
catch(_com_error *e)
{
e->ErrorMessage();
Record->Close();
Record=NULL; return;
}
Record->Close();
Record=NULL;
AfxMessageBox("修改成功!");
应该是:
sSQL.Format("update 订单表 set 订单状态=%d where 订单号=%d",num,num);
你多写了一个from 导致语法错误。