_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
void C管理系统Dlg::OnBnClickedOk()
{
// TODO:
::CoInitialize(NULL);
_variant_t RecordsAffected=3;
HRESULT hr;
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
if(SUCCEEDED(hr))
hr=m_pConnection->Open("Data Source=PC-201204231030;Initial Catalog=HR1;Persist Security Info=True;User ID=sa;Password=a;Pooling=False;","","",adModeUnknown);
if(SUCCEEDED(hr))
hr=m_pConnection->Execute("Insert Into Table1(a,b)values('d','f')",&RecordsAffected,adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
}
m_pConnection->Open( )未指定错误 VC ado sql
答案:1 悬赏:60 手机版
解决时间 2021-02-10 03:10
- 提问者网友:你挡着我发光了
- 2021-02-09 16:05
最佳答案
- 五星知识达人网友:有你哪都是故乡
- 2021-02-09 17:10
_ConnectionPtr m_pConnection;
_RecordsetPtr m_pRecordset;
void C管理系统Dlg::OnBnClickedOk()
{
// TODO:
::CoInitialize(NULL);
HRESULT hr;
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
if(SUCCEEDED(hr))
hr=m_pConnection->Open("Data Source=PC-201204231030;InitialCatalog=HR1;Persist Security Info=True;UserID=sa;Password=a;Pooling=False;","","",adModeUnknown);
if(SUCCEEDED(hr))
hr=m_pConnection->Execute("Insert Into Table1(a,b)values('d','f')",NULL,adCmdText);
}
catch(_com_error &e)
{
AfxMessageBox(e.Description());//获取详细的错误信息
}
}
我不知道你的m_pConnection->Open和("Insert Into Table1(a,b)values('d','f')"语句的正确性,你自己应该知道,其他的没有什么了,
_RecordsetPtr m_pRecordset;
void C管理系统Dlg::OnBnClickedOk()
{
// TODO:
::CoInitialize(NULL);
HRESULT hr;
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection");///创建Connection对象
if(SUCCEEDED(hr))
hr=m_pConnection->Open("Data Source=PC-201204231030;InitialCatalog=HR1;Persist Security Info=True;UserID=sa;Password=a;Pooling=False;","","",adModeUnknown);
if(SUCCEEDED(hr))
hr=m_pConnection->Execute("Insert Into Table1(a,b)values('d','f')",NULL,adCmdText);
}
catch(_com_error &e)
{
AfxMessageBox(e.Description());//获取详细的错误信息
}
}
我不知道你的m_pConnection->Open和("Insert Into Table1(a,b)values('d','f')"语句的正确性,你自己应该知道,其他的没有什么了,
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯