简体   繁体   中英

Connect an SQL to c++ project in visual studio 2015

I'm writting a tic-tac-toe game in c++ and I want to create a hight scores view. The problem is I'm new to DB and now just theory of SQL.

So, how can I add a simple SQL table to my c++ project?

(id INTEGER PRIMARY KEY, name TEXT, hightScore INTEGER)

Looks like just adding to project SQL script file and creating this table not gonna work. How to connect it with my cpp files? Where and how I'll be able to make an INSERT after each new game was played?

Thanks in advance!

To have a simple table you'll need to have a database to set the table up within. The library you will use to communicate with the database is going to depend on which database you are running.

Setting up the needed libraries usually means installing them and updating your linker. This will require some research and effort on your part to make it work, depending on what your particular configuration is.

some ideas:

(for mysql there is mysql/mysql.h which is a free library. ) How to make #include <mysql.h> work?

(for other SQL databases (not free)) http://www.sqlapi.com/

(possible free alternative to sqlapi ) Free alternative to SQLAPI++?

Hopefully that will get you started in the right direction! Good luck.

I have researched about c++ database connectivity and i could find following ways to connect to SQL server database from c++ project.

  1. Using Microsoft's ODBC connection method. Which is a little bit complicate method and requires thorough research to use further. Ref: https://www.techhowtos.com/programming/how-to-connect-to-sql-server-from-visual-c-plus-plus/

  2. Using SQLAP++ Library which is very convenient way to connect to a databse . It Requires to purchase one time license to use commercially.

  3. Using CPPCMS project's CppDB library.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM