Install MySQL ++ in windows with the latest version (3.1.0)

Source: Internet
Author: User

Download the mysql00000000-3.1.0.tar.gz source code package from the official website. decompress the package and find three folders, including "vc2003", "vc2005", and "vc2008, open the project in your vs version to compile MySQL ++. Check the engineering properties before compilation. (There are many projects in the solution. Compile "mysqlpp" only, the header file and the path to the link library are mysql5.1 by default. If you install another version, you must change it. After compilation, a dynamic library and a static library are generated in the debug or release folder. You can create a new path to store these library files and add them to the PATH variable. By now, 99% is successful, double-click "install. "HTA" to install. After installation, it is found that there is an include folder under the installation path, which contains the header file of MySQL ++. With include and Lib, you can write a test code:

Mysqlpp: Connection _ conn; _ Conn. set_option (New mysqlpp: setcharsetnameoption ("GBK"); // set the Chinese Character Set _ Conn. set_option (New mysqlpp: multistatementsoption (true); If (_ Conn. connect ("test", "localhost", "root", "sa", 3306) {int _ id; STD: String _ name; mysqlpp :: query _ query = _ Conn. query ("select * From mytable"); mysqlpp: storequeryresult _ rs = _ query. store (); For (uint I = 0; I <_ rs. num_rows (); I ++) {_ id = atoi (_ rs [I] [0]. c_str (); If (_ rs [I] [1] = mysqlpp: NULL) _ name = "null "; else _ name = _ rs [I] [1]. c_str (); printf ("% d % s \ n", _ id, _ name. c_str ();} _ Conn. disconnect ();}

Running result:
1 Tom
2 null
3 Zhang San

If the link fails or the DLL cannot be found, check whether the generated library file is correctly referenced.

Related Article

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.