关于VC使用ADO的问题?(50分)

  • 主题发起人 主题发起人 changzheng
  • 开始时间 开始时间
C

changzheng

Unregistered / Unconfirmed
GUEST, unregistred user!
这么执行SQL语句,对吗?
sprintf(buf,"delete from ti where TikuID=%d",m_nCurrentSel);
m_pRecordsetTi->Open(_variant_t(buf),theApp.m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
执行程序后说:"完成该操作所需的数据还不可使用"
谢谢,请解答
 
我也有个VC的ADO的问题,一时说不清。
交换QQ或者msn,交流一下好吗?
QQ:76628305
msn: nevergrief@hotmail.com
 
bool CADORecordset::Open(_ConnectionPtr mpdb, LPCTSTR lpstrExec, int nOption)
{
Close();

if(strcmp(lpstrExec, _T("")) != 0)
m_strQuery = lpstrExec;
ASSERT(!m_strQuery.IsEmpty());

m_strQuery.TrimLeft();
BOOL bIsSelect = m_strQuery.Mid(0, strlen("Select ")).CompareNoCase("select ") == 0 &&
nOption == openUnknown;
try
{
m_pRecordset->CursorType = adOpenStatic;
m_pRecordset->CursorLocation = adUseClient;
if(bIsSelect || nOption == openQuery || nOption == openUnknown)
m_pRecordset->Open((LPCSTR)m_strQuery, _variant_t((IDispatch*)mpdb, true),
adOpenStatic, adLockOptimistic, adCmdUnknown);
else
if(nOption == openTable)
m_pRecordset->Open((LPCSTR)m_strQuery, _variant_t((IDispatch*)mpdb, true),
adOpenKeyset, adLockOptimistic, adCmdTable);
else
if(nOption == openStoredProc)
{
m_pCmd->ActiveConnection = mpdb;
m_pCmd->CommandText = _bstr_t(m_strQuery);
m_pCmd->CommandType = adCmdStoredProc;

m_pRecordset = m_pCmd->Execute(NULL, NULL, adCmdText);
}
else
{
TRACE( "Unknown parameter. %d", nOption);
return false;
}
}
catch(_com_error &e)
{
dump_com_error(e);
return false;
}
return m_pRecordset != NULL;
}
bool CADORecordset::Open(LPCTSTR lpstrExec, int nOption)
{
ASSERT(m_pConnection != NULL);
ASSERT(m_pConnection->GetState() != adStateClosed);
return Open(m_pConnection, lpstrExec, nOption);
}
 
接受答案了.
 
后退
顶部