• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            kenlistian

            厚積薄發. 勤為槳,思為帆

               :: 首頁 :: 新隨筆 ::  :: 聚合  :: 管理 ::
              73 隨筆 :: 4 文章 :: 22 評論 :: 0 Trackbacks
            使用_commandPtr 處理存儲過程時,當在存儲過程中需要返回結果集合和返回參數時,一般在任何語言調用的ado中
            存儲過程控件都無法同時返回,這里http://www.pkvs.com/data/mssql/19323.html給了我們答案。

            使用CreateParameter(),而是調用CommandPtr的Refresh()函數先從數據庫中查詢參數.
            _ConnectionPtr m_pConn;
            m_pConn.CreateInstance(__uuidof(Connection));
            m_pConn->Open("driver={SQL Server};server=127.0.0.1;DATABASE=pub;UID=sa;PWD=", "","",0);

            _CommandPtr  m_pCommand;
            m_pCommand.CreateInstance(__uuidof(Command));
            _RecordsetPtr m_pRecordset;
            m_pRecordset.CreateInstance(__uuidof(Recordset));

            m_pCommand->ActiveConnection = m_pConn;
            m_pCommand->CommandText = "SP_XX";              //存儲過程名
            m_pCommand->PutCommandType(adCmdStoredProc);
            m_pCommand->Parameters->Refresh();              //從數據庫查詢參數信息
            //我不建議使用refresh,這個內部的處理速度還不如用createparamter好,

            long cnt = m_pCommand->Parameters->GetCount();//取得參數的個數
            for(long k=1;k<cnt;k++)
            { //由于ADO中認為返回值是第一個參數,因此這里用k=1濾掉第一個參數
                   m_pCommand->Parameters->GetItem(k)->Value = XXX;//按存儲過程的參數順序給參數賦值
            }

            以執行這個存儲過程了,返回m_pRecordset將返回集合,
                m_pRecordset = m_pCommand->Execute(0,0,adCmdStoredProc);
            這個時候,如果接下來用
               _variant_t ret_val = m_pCommand->Parameters->GetItem((long)0)->Value;
            那么將得不到值
            而如果像下面這樣調用的話就可以得到返回值了
            m_pRecordset->Close();
            _variant_t output_para = m_pCommand->Parameters->GetItem((long)0)->Value;
            MS ADO.net給這一現象的回復是:
             You can think of a stored procedure as a function in your code. The function doesn’t return a value until it has executed all of its code. If the stored procedure returns results and you haven’t finished processing these results, the stored procedure hasn’t really finished executing. Until you’ve closed the DataReader, the return and output parameters of your Command won’t contain the values returned by your stored procedure.
            也就是說Execute()函數應該看成是直到m_pRecordset關掉以后才會正確返回.


            posted on 2007-09-18 10:17 kenlistian 閱讀(618) 評論(0)  編輯 收藏 引用
            99久久国产免费福利| 老男人久久青草av高清| 大香网伊人久久综合网2020| 精品一久久香蕉国产线看播放| 开心久久婷婷综合中文字幕| 久久人人爽人人爽人人片AV麻烦 | 97精品国产97久久久久久免费| 久久精品不卡| 色婷婷久久综合中文久久蜜桃av| 久久中文字幕一区二区| 一本色道久久88精品综合| 国产L精品国产亚洲区久久| 国产aⅴ激情无码久久| 久久综合色区| 久久e热在这里只有国产中文精品99| 亚洲AV无码久久精品色欲| 尹人香蕉久久99天天拍| 国产精品99久久久久久猫咪 | 久久综合综合久久狠狠狠97色88 | 久久精品aⅴ无码中文字字幕不卡| 久久www免费人成看国产片| 国产精品久久久久国产A级| 亚洲色欲久久久综合网东京热| 欧美亚洲日本久久精品| 久久久久久国产精品美女| 久久精品国产第一区二区三区| 久久久久久久91精品免费观看| 久久人人超碰精品CAOPOREN| 精品乱码久久久久久夜夜嗨| 曰曰摸天天摸人人看久久久| 久久99国产亚洲高清观看首页| 久久久婷婷五月亚洲97号色| 欧洲精品久久久av无码电影| 人妻精品久久久久中文字幕69| 久久91精品国产91久| 久久婷婷五月综合国产尤物app| 色综合久久久久综合99| 久久久久人妻一区二区三区| 中文字幕久久波多野结衣av| 久久精品国产亚洲av麻豆色欲| 少妇内射兰兰久久|