m_bConnected = false;
m_pConnection = NULL;
m_pRecordset = NULL;
m_pCommand = NULL;::CoInitialize(NULL);
_ParameterPtr param=null;
_variant_t vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
//初始化记录集指针
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->putref_ActiveConnection(m_pConnection);
m_pRecordset->put_CacheSize(5000);
m_pRecordset->PutLockType(adLockReadOnly);
m_pRecordset->PutCursorType(adOpenStatic);
//初始化命令指针
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection =m_pConnection;
m_pCommand->CommandType= adCmdStoredProc;
m_pCommand->CommandText="insertzltable_proc";
//创建input参数
param=m_pCommand->CreateParameter("",adVarChar,adParamInput,strzlmc.GetLength()+1,(_variant_t)strzlmc);
m_pCommand->Parameters->Append(param);
param=m_pCommand->CreateParameter("",adVarChar,adParamInput,sizeof(long),(_variant_t)strzjs);
m_pCommand->Parameters->Append(param);
long tmp;
tmp=m_pCommand->Parameters->GetCount();
m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
strRet +=(_bstr_t)m_pCommand->Parameters->Item[(short)49]->Value;
//释放
m_pCommand.Release();
m_pRecordset.Release();
m_pConnection.Release();
param.Release();
::CoUninitialize();
m_pConnection = NULL;
m_pRecordset = NULL;
m_pCommand = NULL;::CoInitialize(NULL);
_ParameterPtr param=null;
_variant_t vtEmpty (DISP_E_PARAMNOTFOUND, VT_ERROR);
//初始化记录集指针
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->putref_ActiveConnection(m_pConnection);
m_pRecordset->put_CacheSize(5000);
m_pRecordset->PutLockType(adLockReadOnly);
m_pRecordset->PutCursorType(adOpenStatic);
//初始化命令指针
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection =m_pConnection;
m_pCommand->CommandType= adCmdStoredProc;
m_pCommand->CommandText="insertzltable_proc";
//创建input参数
param=m_pCommand->CreateParameter("",adVarChar,adParamInput,strzlmc.GetLength()+1,(_variant_t)strzlmc);
m_pCommand->Parameters->Append(param);
param=m_pCommand->CreateParameter("",adVarChar,adParamInput,sizeof(long),(_variant_t)strzjs);
m_pCommand->Parameters->Append(param);
long tmp;
tmp=m_pCommand->Parameters->GetCount();
m_pCommand->Execute(NULL,NULL,adCmdStoredProc);
strRet +=(_bstr_t)m_pCommand->Parameters->Item[(short)49]->Value;
//释放
m_pCommand.Release();
m_pRecordset.Release();
m_pConnection.Release();
param.Release();
::CoUninitialize();
解决方案 »
- vc2008 如何创建圆形按钮
- 提取HTML中<P> text </P>中内容的一些问题
- 程序用了MSXML,发布给客户那里还需要安装msxml sdk吗?
- 请高手指点,程序编译完后运行有个问题
- select -- console程序,怎样在没有输入时,定时输出?
- 关于动态库调用的问题、?再线等
- 我问一个问题
- 特急,关于文档视图的基础,五分钟内希望能给个答案
- asp中调用自定义com件出现的问题
- 请问哪里有关于网络编程方面好一点的书可下或可买?
- *********正投简历呢,看到一家公司招聘没给笑死,招精通精通Java、C++、VC++、C#的工程师,月薪1500
- 我在msdn上查到CClientDC( CWnd* pWnd ),为什么有些程序中参数用this呢
if(m_pConnection->State)
m_pConnection->Close(); ///如果已经打开了连接则关闭它,也不要关两次了其它的不用操心,也不要m_pConnection.Release();了。