不知道为什么有输出参数就出错。
解决方案 »
- MySQL数据库:求SQL语句一条,思路也行
- mysql 存储过程中先查询后插入的问题
- 高手请帮忙。。。
- 在繁体WINXP下,客户端用ODBC为何连不上MYSQL服务器啊
- APPSERV 如何禁止远程访问 phpMyAdmin
- C#连接mysql出现乱码
- 请问高手,mysqld-max-nt与mysqld-nt启动服务有什么不同?
- mysql 插入报错#1105 - Too long comment for table 'kc'
- mysql分区问题
- mysql如何导入2GB大的里面含有7个表的.xml数据文件
- 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是主键 自增。