UpdateData(TRUE);
int pos=m_list1.GetSelectionMark();
::CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
try
{
pConn.CreateInstance("ADODB.Connection");
_bstr_t strConnect="Provider=MSDASQL.1;Persist Security Info=False;Initial Catalog=book_204;Data Source=wuwenlin";
pConn->Open(strConnect,"","",adModeUnknown);
}
catch(...)
{
AfxMessageBox("fail to connect db",0,0);
} // AfxMessageBox("success",0,0); pRst=pConn->Execute("select * from dbo.kucun_204",NULL,adCmdText);
try
{
pRst->Move(pos,vtMissing);
pRst->Delete(adAffectCurrent);
pRst->Update();
}
catch(...)
{
AfxMessageBox("fail to del ",0,0);
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
::CoUninitialize();
m_list1.DeleteAllItems();
这个数据库是能连接上的 但删除不了数据 啊啊 这表就这一个 不存在外键什么的
int pos=m_list1.GetSelectionMark();
::CoInitialize(NULL);
_ConnectionPtr pConn(__uuidof(Connection));
_RecordsetPtr pRst(__uuidof(Recordset));
try
{
pConn.CreateInstance("ADODB.Connection");
_bstr_t strConnect="Provider=MSDASQL.1;Persist Security Info=False;Initial Catalog=book_204;Data Source=wuwenlin";
pConn->Open(strConnect,"","",adModeUnknown);
}
catch(...)
{
AfxMessageBox("fail to connect db",0,0);
} // AfxMessageBox("success",0,0); pRst=pConn->Execute("select * from dbo.kucun_204",NULL,adCmdText);
try
{
pRst->Move(pos,vtMissing);
pRst->Delete(adAffectCurrent);
pRst->Update();
}
catch(...)
{
AfxMessageBox("fail to del ",0,0);
}
pRst->Close();
pConn->Close();
pRst.Release();
pConn.Release();
::CoUninitialize();
m_list1.DeleteAllItems();
这个数据库是能连接上的 但删除不了数据 啊啊 这表就这一个 不存在外键什么的
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货