代码如下,运行到m_pRecordset->Open时报错,Runtime error!
请大虾指点 CString strSql="select * from user where id=";
CString strId; m_user.GetWindowText(strId);
strSql=strSql+strId; BSTR bstrSQL = strSql.AllocSysString();
m_pRecordset->Open(bstrSQL,_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
if (m_pRecordset->adoEOF && m_pRecordset->BOF)
{
if (MessageBox("没有此用户,您要重新输入吗?!","提示",MB_YESNO)==IDYES)
{
m_user.SetWindowText(NULL);
m_user.SetFocus();
}
}
请大虾指点 CString strSql="select * from user where id=";
CString strId; m_user.GetWindowText(strId);
strSql=strSql+strId; BSTR bstrSQL = strSql.AllocSysString();
m_pRecordset->Open(bstrSQL,_variant_t((IDispatch*)m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
if (m_pRecordset->adoEOF && m_pRecordset->BOF)
{
if (MessageBox("没有此用户,您要重新输入吗?!","提示",MB_YESNO)==IDYES)
{
m_user.SetWindowText(NULL);
m_user.SetFocus();
}
}
解决方案 »
- 请教下,MFC输出PDF文件如何翻页???
- CreateProcessWithLogon 与 CreateProcessAsUser讨论,有没有哪个大师可以解决,高分相送
- 有个进程的问题
- 刚开始学习C++, 有很多东西不懂,请高手指教.
- 请教各位,学windows API编程哪里有比较好的实例可以边理论边实践????
- 我自己写的一个类 用到了CSocket 那事件写在那里阿 分不是问题
- 请问向量乘以一个模型矩阵,对向量进行了怎样的变换?
- VC的那个工具Error Lookup是怎么编的?他的那些内容都存在什么地方?如果我能在程序中直接利用,这样在调试和出错信息提示方面都方便了很
- VC/MFC
- 何谓“VC程序员”!
- 关于界面友好,功能较为完善Grid的问题!
- 请各位大侠帮我看看,多谢啦。
CoInitialize(NULL); try
{
hr=m_pConnection.CreateInstance(__uuidof(Connection));
hr=m_pRecordset.CreateInstance(__uuidof(Recordset));
if (SUCCEEDED(hr))
{
hr=m_pConnection->Open("Driver={SQL Server};Server=DEVELOP2;DATABASE=rms","","",0);
}
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
user是一个函数名。
系统无法分辨他是字段还是函数或其他。所以加上[]指示为字段
最好不要用这两个作字段名。