Build C/C++ Applications Using MySQL Connector and Visual Studio 2022 | Connect C/C++ to MySQL

preview_player
Показать описание
How to build C/C++ programs using the MySQL connector/c++ and Visual Studio 2022 on Windows. How to connect C/C++ applications to MySQL database.
**********************

***********************************

🔥 *Complete Udemy Courses* :

⬇️ *Free Document Proofreading* ⬇️
Рекомендации по теме
Комментарии
Автор

#include <stdlib.h>
#include <iostream>

#include "mysql_connection.h"
#include <cppconn/driver.h>
#include <cppconn/exception.h>
#include
using namespace std;

//for demonstration only. never save your password in the code!
const string server = "tcp://127.0.0.1:3306";
const string username = "root";
const string password = "";

int main()
{
sql::Driver *driver;
sql::Connection *con;
sql::Statement *stmt;
sql::PreparedStatement *pstmt;

try
{
driver = get_driver_instance();
con = driver->connect(server, username, password);
}
catch (sql::SQLException e)
{
cout << "Could not connect to server. Error message: " << e.what() << endl;
system("pause");
exit(1);
}

//please create database "quickstartdb" ahead of time


stmt = con->createStatement();
stmt->execute("DROP TABLE IF EXISTS inventory");
cout << "Finished dropping table (if existed)" << endl;
stmt->execute("CREATE TABLE inventory (id serial PRIMARY KEY, name VARCHAR(50), quantity INTEGER);");
cout << "Finished creating table" << endl;
delete stmt;

pstmt = con->prepareStatement("INSERT INTO inventory(name, quantity) VALUES(?, ?)");
pstmt->setString(1, "banana");
pstmt->setInt(2, 150);
pstmt->execute();
cout << "One row inserted." << endl;

pstmt->setString(1, "orange");
pstmt->setInt(2, 154);
pstmt->execute();
cout << "One row inserted." << endl;

pstmt->setString(1, "apple");
pstmt->setInt(2, 100);
pstmt->execute();
cout << "One row inserted." << endl;

delete pstmt;
delete con;
system("pause");
return 0;
}

BoostMyTool
Автор

This is the ONLY video that helped me, there isn't much info about C++ on YouTube, Thanks ALOT!

geraldmacherechedze
Автор

Thanks for both the tutorial AND example source. I used to hate "excercise left to the student." It's been some time since working with VC++ and SQL, this serves as a great refresher!

Bob-Is-A-PotterNow
Автор

Thanks pal. You are the only one who can explain me how to include mySQL to cpp code)

aleksandrguz
Автор

Thank very very very much man, I don't know what I would have done without your guide, really thanks!

nevell
Автор

I LOVE YOU!!!!
The only one mornal guide that i found during the whole day

yegorkliushin
Автор

Thanks so much dude, you really saved me there. Quick and simple.

Auditor
Автор

i followed the instructions but run into "application error (0xc0150002)" on debugging

baageledilepodisi
Автор

Thanks for the tutorial! You're a life saver.

sudarson
Автор

Very nice content sir. It was getting very difficult for me to connect c++ and mysql but you helped me a lot 🥺🥺

anishkashyap
Автор

great! it worked for me
Thanks a lot <3

nguyenxuanthong
Автор

wait this video only shows how to write data into sql....but how do i read info frm sql into c++?

adityarajamani
Автор

FRIEND THANK YOU SO MUCH! I 3 COULD NOT CONNECT THE LIBRARY TO MY PROJECT! YOU ARE THE BEST HINDUS I HAVE EVER MEET AND WILL MEET IN THE FUTURE!

onlyc
Автор

Thank you for this video who was really useful. Something that I wanted to say however, is that I immediately knew you were Tunisian from the 2 first seconds. Man fallatch sout tounsi mebin lelef 😂. Barakallahou fik khouya !

essersr-
Автор

What about newer versions of VSC? How do I access the project's properties there?

footballvids
Автор

Thank you for the video. I did as you but when bulding the prject link errors (LNK2001) appear. I don't why. Could you help me if you know the solution. I am using Visual Studio 2022.

shahinabdullayev
Автор

cannot open source file mysql_connection.h and others, what should I do?

elshodnematov
Автор

Thnak you very much, you solve my problem.

barok
Автор

nice guide bro, thank u so mutch u angel from the sky, whoo help in hard situation and more smart than all people in Internet
❤❤

mode-
Автор

OH MY GOD THANKS I LOVE YOU MY BROTHER ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤

vlados