« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
|
统计 |
blog名称:小雨 日志总数:262 评论数量:1273 留言数量:15 访问次数:4667379 建立时间:2005年1月8日 |
| 
|
W3CHINA Blog首页 管理页面 写新日志 退出
[知识积累]vc 访问带返回值的存储过程 ,纯粹记录免得到处找 |
小雨 发表于 2009/3/19 20:35:53 | #import "MSADO15.DLL" no_namespace rename("EOF","rsEOF")
void CTestDlg::OnOK() {CoInitialize(NULL);
// Define ADO object pointers. // Initialize pointers on define. // These are in the ADODB:: namespace. _CommandPtr pcmdByRoyalty = NULL;
_ConnectionPtr pConnection = NULL; _ParameterPtr m_pParam;
_bstr_t strCnn("Provider=sqloledb;Data Source=127.0.0.1;initial Catalog=NetInfo;User Id=sa;Password=123");
//Open a Connection. pConnection.CreateInstance(__uuidof(Connection)); pConnection->Open(strCnn,"","",NULL); pConnection->CursorLocation = adUseClient;
//Open Command Object with one Parameter pcmdByRoyalty.CreateInstance(__uuidof(Command)); pcmdByRoyalty->CommandText = "UserLogIn"; pcmdByRoyalty->CommandType = adCmdStoredProc;
pcmdByRoyalty->ActiveConnection = pConnection;//连接字符串
//Define Integer/variant. m_pParam = pcmdByRoyalty->CreateParameter( "return_v",adInteger,adParamReturnValue,sizeof(int)); pcmdByRoyalty->Parameters->Append(m_pParam);
CString name="123456"; m_pParam = pcmdByRoyalty->CreateParameter("@name",adVarChar,adParamInput,30,(LPTSTR)(LPCTSTR)name); pcmdByRoyalty->Parameters->Append(m_pParam);
CString pwd="123456"; m_pParam = pcmdByRoyalty->CreateParameter("@pwd",adVarChar,adParamInput,30,(LPTSTR)(LPCTSTR)pwd); pcmdByRoyalty->Parameters->Append(m_pParam);
m_pParam = pcmdByRoyalty->CreateParameter("@type",adVarChar,adParamInput,30,(LPTSTR)(LPCTSTR)"s"); pcmdByRoyalty->Parameters->Append(m_pParam); m_pParam = pcmdByRoyalty->CreateParameter("@address",adVarChar,adParamInput,30,(LPTSTR)(LPCTSTR)"127.0.0.1"); pcmdByRoyalty->Parameters->Append(m_pParam);
m_pParam = pcmdByRoyalty->CreateParameter("@cip",adVarChar,adParamInput,30,(LPTSTR)(LPCTSTR)"127.0.0.1"); pcmdByRoyalty->Parameters->Append(m_pParam);
m_pParam = pcmdByRoyalty->CreateParameter("@isopen",adInteger,adParamInput,sizeof(int),(LPTSTR)(LPCTSTR)"1"); pcmdByRoyalty->Parameters->Append(m_pParam); pcmdByRoyalty->Execute(NULL,NULL,adCmdStoredProc); int Id=0; try{
Id= pcmdByRoyalty->Parameters->GetItem((long)0)->Value.intVal; } catch(_com_error e) { AfxMessageBox((LPCSTR)e.Description()); return; }
pConnection->Close(); CDialog::OnOK();}
|
阅读全文(4454) | 回复(1) | 编辑 | 精华 |
回复:vc 访问带返回值的存储过程 ,纯粹记录免得到处找 |
nrzj(游客)发表评论于2009/3/20 22:11:08 | #import "MSADO15.DLL" rename_namespace ("ADO")rename("EOF","rsEOF")
|
个人主页 | 引用回复 | 主人回复 | 返回 | 编辑 | 删除 |
» 1 »
|