MySQL++调用存储过程
2009-10-17 14:56
253 查看
其实与普通调用SQL没有什么区别,只是连接方式必须使用CLIENT_MULTI_STATEMENTS(多行语句)。样例代码如下:
Code:
//////////////////////////////////////////////////////////////////////////
// CopyRight(c) 2009, YOYO, All Rights Reserved.
// Author: LIN YiQian
// Created: 2009/10/14
// Describe: MySQL++调用存储过程
//////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
#pragma comment(lib, "mysqlpp_d.lib")
#else
#pragma comment(lib, "mysqlpp.lib")
#endif
#include <mysql++.h>
#include <string>
#include <iostream>
using namespace mysqlpp;
using namespace std;
int main(void)
{
Connection conn(false);
conn.set_option(new mysqlpp::MultiStatementsOption(CLIENT_MULTI_STATEMENTS));
if (conn.connect("test", "localhost", "root", "root", 3306))
{
Query query = conn.query();
char* pszSQL = "call querydate()";
StoreQueryResult pResult = query.store(pszSQL, strlen(pszSQL));
cout << pResult[0][0] << endl;
}
else
{
cout << "连接失败!" << endl;
}
system("pause");
return 0;
}
Code:
//////////////////////////////////////////////////////////////////////////
// CopyRight(c) 2009, YOYO, All Rights Reserved.
// Author: LIN YiQian
// Created: 2009/10/14
// Describe: MySQL++调用存储过程
//////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
#pragma comment(lib, "mysqlpp_d.lib")
#else
#pragma comment(lib, "mysqlpp.lib")
#endif
#include <mysql++.h>
#include <string>
#include <iostream>
using namespace mysqlpp;
using namespace std;
int main(void)
{
Connection conn(false);
conn.set_option(new mysqlpp::MultiStatementsOption(CLIENT_MULTI_STATEMENTS));
if (conn.connect("test", "localhost", "root", "root", 3306))
{
Query query = conn.query();
char* pszSQL = "call querydate()";
StoreQueryResult pResult = query.store(pszSQL, strlen(pszSQL));
cout << pResult[0][0] << endl;
}
else
{
cout << "连接失败!" << endl;
}
system("pause");
return 0;
}
相关文章推荐
- java, mybatis, 调用mysql存储过程
- mysql存储过程学习及java调用存储过程
- hibernate调用mysql存储过程
- Hibernate框架下调用Mysql存储过程
- hibernate 调用mysql存储过程
- mysql存储过程学习及java调用存储过程(转载)
- MySQL Connector/C++ 调用存储过程
- c/c++中调用mysql存储过程
- mybatis 调用mysql存储过程 带输出输入参数
- mysql 存储过程,以及mybatis如何调用
- mysql C API 调用存储过程
- mysql存储过程一次连接多次调用失败的问题解决
- Python通过调用mysql存储过程实现更新数据功能示例
- mysql存储过程学习及java调用存储过程
- PHP如何调用mysql存储过程
- Node.js调用mysql的存储过程
- MyBatis—调用mysql存储过程 带输出输入参数
- MYSQL中存储过程的创建,调用及语法
- Java调用MySQL存储过程
- 简单的存储过程编写及MySQL中event调用