其实与普通调用SQL没有什么区别,只是连接方式必须使用CLIENT_MULTI_STATEMENTS(多行语句)。样例代码如下:
- //
- // 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;
- }