Summary of C ++ methods for operating mysql (3)

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.