新聞中心
ADO參數(shù)的取值依次為adInteger、adChar、adChar、adSingle,adChar;Direction參數(shù)的取值依次為adParameterIn、adParameterIn、adParameterIn、adParameterOut、adParameterOut;

成都創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè)、鄰水網(wǎng)絡(luò)推廣、微信小程序開(kāi)發(fā)、鄰水網(wǎng)絡(luò)營(yíng)銷、鄰水企業(yè)策劃、鄰水品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供鄰水建站搭建服務(wù),24小時(shí)服務(wù)熱線:028-86922220,官方網(wǎng)址:www.cdcxhl.com
對(duì)于輸入ADO參數(shù),Size的值可以根據(jù)實(shí)際數(shù)值來(lái)定,對(duì)于輸出參數(shù),最好是根據(jù)定義確定(上例中ReturnInfo參數(shù)的Size值可以取為100)。
關(guān)于獲取Output的參數(shù)獲取ourput參數(shù)是大家最關(guān)注的問(wèn)題,同時(shí)也是最“難”的問(wèn)題,因?yàn)榘凑諘?shū)本上的寫(xiě)法,經(jīng)常獲得不了Output參數(shù),ADO參數(shù)其實(shí)這個(gè)問(wèn)題很容易解決:在調(diào)用_CommandPtr的Execute方法時(shí),ADO參數(shù)寫(xiě)成cmmd->Execute(NULL, NULL, adCmdStoredProc);而不要寫(xiě)成RecordsetPtr rec = cmmd->Execute(NULL, NULL, adCmdStoredProc);#t#
也就是說(shuō),不取返回值(我不知道這是為什么,但是相信我,事情就是這樣)。ADO參數(shù)這句執(zhí)行完后,使用cmmd->Parameters->GetItem("XXXXXX")->GetValue();輸出參數(shù)的名稱就可以獲得輸出參數(shù)的值了。
以下是一個(gè)通過(guò)ADO調(diào)用存儲(chǔ)過(guò)程的部分代碼:
- _ParameterPtr param;
- param = cmmd->CreateParameter(""/*NetType*/,adTinyInt, adParamInput,
- sizeof(BYTE),(BYTE)(m_nNetType+1));
- cmmd->Parameters->Append(param);
- param = cmmd->CreateParameter(""/*Name*/,adVarChar, adParamInput,
- m_strName.GetLength()+1, _variant_t(m_strName));
- cmmd->Parameters->Append(param);
- param = cmmd->CreateParameter(""/*Desp*/,adVarChar, adParamInput,
- m_strDesp.GetLength()+1, _variant_t(m_strDesp));
- cmmd->Parameters->Append(param);
- param = cmmd->CreateParameter("NewNetID"/*NetID*/,adInteger, adParamOutput,
- sizeof(long), (long)m_nNewNetID);//返回參數(shù),返回新建的網(wǎng)絡(luò)的ID
- cmmd->Parameters->Append(param);
- cmmd->CommandText=_bstr_t("GSDT_NewNet");//存儲(chǔ)過(guò)程的名稱
- cmmd->ActiveConnection = m_pConPtr;//需要使用的ADO連接
- cmmd->CommandType=adCmdStoredProc;
- //注意下面的一行代碼,如果你寫(xiě)成這樣,就獲得不了返回參數(shù)的值
- //_RecordsetPtr rec = cmmd->Execute(NULL, NULL, adCmdStoredProc);
- //我不知道這是為什么,但事實(shí)就是這樣:)
- cmmd->Execute(NULL, NULL, adCmdStoredProc);
- m_nNewNetID=(long)cmmd->Parameters->GetItem("NewNetID")->GetValue();//通過(guò)參數(shù)返回值
- cmmd.Detach();
- ActiveX Data Objects (ADO) enables you to write a client application to access and manipulate data in a database server through a provider.
- ADO's primary benefits are ease of use, high speed, low memory overhead, and a small disk footprint.
- This sample project is for ADODB, an implementation of ADO optimized for use with Microsoft OLE DB providers, including the Microsoft ODBC provider for OLE DB.
- Using this we can execute stored procedure, pass arguments and retrieve value. To use this sample you will have to create the two stored procedures mentioned below.
- For using this project you need MFC 5.0 OR above + ADO in your machine.
- {
本文標(biāo)題:詳細(xì)介紹ADO參數(shù)相關(guān)問(wèn)題
網(wǎng)頁(yè)網(wǎng)址:http://m.fisionsoft.com.cn/article/dhjgijp.html


咨詢
建站咨詢
