ado调用mysql的存储过程,带输出参数,出错。 不知道为什么有输出参数就出错。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 conn.execute "call myproc(@x)"rs.open "select @x", conn 代码:#include <stdio.h>#include <tchar.h>#include <locale>#include <Windows.h>#import "C:\Program Files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")int _tmain(int argc, _TCHAR* argv[]){ HRESULT hr = ::OleInitialize(NULL); _bstr_t str("Driver={MySQL ODBC 5.1 Driver};SERVER=127.0.0.1;UID=root;PWD=root;DATABASE=face;PORT=3306"); _CommandPtr pCmd = NULL; _RecordsetPtr pRecordset = NULL; _ConnectionPtr m_pConnection = NULL; hr = m_pConnection.CreateInstance(__uuidof(Connection)); try { hr = m_pConnection->Open(str,"","",adModeUnknown); } catch(_com_error e)///捕捉异常 { printf(e.Description()); getchar(); return 0; } hr = pCmd.CreateInstance(__uuidof(Command)); pCmd->ActiveConnection = m_pConnection; pCmd->CommandText = _bstr_t("proc_tblModelInfo_Insert"); pCmd->CommandType = adCmdStoredProc; _ParameterPtr m_pParam; hr = m_pParam.CreateInstance("ADODB.Parameter"); m_pParam = pCmd->CreateParameter("id",adInteger,adParamOutput,sizeof(int)); pCmd->Parameters->Append(m_pParam); pRecordset.CreateInstance(_uuidof(Recordset)); try { pRecordset = pCmd->Execute(NULL,NULL,adCmdStoredProc); } catch (_com_error e) { printf(e.Description()); getchar(); } VARIANT var = {0}; m_pParam->get_Value(&var); ::OleUninitialize(); getchar(); return 0;}打印错误消息[MySQL][ODBC 5.1 Driver][mysqld-5.5.24]OUT or INOUT argument 1 for routine face.proc_tblModelInfo_Insert is not a variable or NEW pseudo-variable in BEFORE trigger这里是存储过程DELIMITER $$drop procedure if exists proc_tblModelInfo_Insert ;create procedure proc_tblModelInfo_Insert(out ID int)begin insert into ModelInfo() values(); set ID = (select max('id') from ModelInfo);END $$DELIMITER ;id是主键 自增。 查询汇总问题 超级问题 ---MY SQL 晕了 求助:mysql(系统自带数据库)中各表的意义 有道题怎么做MySQL就是不认。。大家帮帮忙 关于mysql server版本 mysql函数能否实现这样的功能? MySQL、视图、索引 关于表只可读的问题 mySql编码问题 mysql分布式操作问题 mysql group by limit 查詢 MySQL Command Line Client显示中文的部分为空,不是乱码
rs.open "select @x", conn
#include <tchar.h>
#include <locale>
#include <Windows.h>
#import "C:\Program Files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF")int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr = ::OleInitialize(NULL);
_bstr_t str("Driver={MySQL ODBC 5.1 Driver};SERVER=127.0.0.1;UID=root;PWD=root;DATABASE=face;PORT=3306");
_CommandPtr pCmd = NULL;
_RecordsetPtr pRecordset = NULL;
_ConnectionPtr m_pConnection = NULL;
hr = m_pConnection.CreateInstance(__uuidof(Connection));
try
{
hr = m_pConnection->Open(str,"","",adModeUnknown);
}
catch(_com_error e)///捕捉异常
{
printf(e.Description());
getchar();
return 0;
}
hr = pCmd.CreateInstance(__uuidof(Command));
pCmd->ActiveConnection = m_pConnection;
pCmd->CommandText = _bstr_t("proc_tblModelInfo_Insert");
pCmd->CommandType = adCmdStoredProc;
_ParameterPtr m_pParam;
hr = m_pParam.CreateInstance("ADODB.Parameter"); m_pParam = pCmd->CreateParameter("id",adInteger,adParamOutput,sizeof(int));
pCmd->Parameters->Append(m_pParam); pRecordset.CreateInstance(_uuidof(Recordset)); try
{
pRecordset = pCmd->Execute(NULL,NULL,adCmdStoredProc);
}
catch (_com_error e)
{
printf(e.Description());
getchar();
} VARIANT var = {0};
m_pParam->get_Value(&var); ::OleUninitialize();
getchar();
return 0;
}
打印错误消息
[MySQL][ODBC 5.1 Driver][mysqld-5.5.24]OUT or INOUT argument 1 for routine face.
proc_tblModelInfo_Insert is not a variable or NEW pseudo-variable in BEFORE trig
ger
这里是存储过程
DELIMITER $$
drop procedure if exists proc_tblModelInfo_Insert ;
create procedure proc_tblModelInfo_Insert(
out ID int
)
begin
insert into ModelInfo() values();
set ID = (select max('id') from ModelInfo);
END $$
DELIMITER ;id是主键 自增。