C ++ uses mysql ++ to operate mysql
Use vs2013 and 64-bit msql 5.6.16 for operations
For the database names and table data used in the project, refer to the introduction in C ++ mysql operation method summary (1 ).
Mysql ++ is an officially released C ++ language API designed for MySQL. Mysql ++ is the re-encapsulation of Mysql's C-Api. It is developed and written using STL (Standard Template Language, it also provides a mechanism for C ++ developers to operate databases as conveniently as operating STL containers.
Http://tangentsoft.net/mysql++/
1. Mysql ++ compilation (VS2013)
1. Open mysql ++. sln in vc2008 under mysql-3.2.1, and you will be prompted to upgrade it. Click OK.
2. Most of the projects opened are examples. We only need to compile mysqlpp to obtain the mysqlpp_d.dll and mysqlpp_d.lib needed for generation (under debug)
Or mysqlpp. dll and mysqlpp. lib (under release)
3. Add D: \ Program Files \ MySQL Server 5.6 \ include to the inclusion directory of the mysqlpp Project (depending on the specific path)
# Include <mysql ++. h >#include <iostream >#include <iomanip> using namespace std; int main (int argc, char * argv []) {mysqlpp: Connection conn (false); mysqlpp:: SetCharsetNameOption * opt = new mysqlpp: SetCharsetNameOption ("gbk"); conn. set_option (opt); if (conn. connect ("booktik", "localhost", "root", "123456") {conn. query ("set names 'gbk'"); mysqlpp: Query query = conn. query ("select * from book"); mysqlpp: UseQueryResult res = query. use (); if (res) {while (mysqlpp: Row row = res. fetch_row () {cout <setw (9) <"BookName:" <row ["bookname"] <endl; cout <setw (9) <"Size:" <row ["size"] <endl ;}} else {cerr <"Failed to get item list:" <query. error () <endl; return 1 ;}} else {cerr <"DB connection failed:" <conn. error () <endl; return 1;} system ("pause ");}
Running result