#include #include #include "mysql_connection.h" #include #include #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 execute("DROP TABLE IF EXISTS inventory"); cout setInt(2, 150); pstmt->execute(); cout setInt(2, 154); pstmt->execute(); cout setInt(2, 100); pstmt->execute(); cout
@didacemanirakiza10363 жыл бұрын
I need code or video about c program. I see this is c++. Thanks
@Bob-Is-A-PotterNow2 жыл бұрын
@@didacemanirakiza1036 try Google "c program connect to mysql database" many source examples. You do realize you'll be seeing very old postings in most cases?
@buddgaf13042 жыл бұрын
thank you
@geraldmacherechedze5197 Жыл бұрын
This is the ONLY video that helped me, there isn't much info about C++ on KZbin, Thanks ALOT!
@Bob-Is-A-PotterNow2 жыл бұрын
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!
@yegorkliushin7705 Жыл бұрын
I LOVE YOU!!!! The only one mornal guide that i found during the whole day
@aleksandrguz6508 Жыл бұрын
Thanks pal. You are the only one who can explain me how to include mySQL to cpp code)
@nevell60692 жыл бұрын
Thank very very very much man, I don't know what I would have done without your guide, really thanks!
@madiyarkuandyk35509 күн бұрын
YOU!!! Thank you!! REALLY help me!
@rei_sen76463 ай бұрын
I was having trouble connecting my c++ app to mysql, and the thing about choosing "debug" or "release" really helped me. It ended up being the main thing preventing me from completing what I wanted to do.
@Auditor13372 жыл бұрын
Thanks so much dude, you really saved me there. Quick and simple.
@sudarson25 Жыл бұрын
Thanks for the tutorial! You're a life saver.
@Evans19972 жыл бұрын
It worked! thank you very much!
@nguyenxuanthong3179 Жыл бұрын
great! it worked for me Thanks a lot
@HafizMuhammadRizwan-l9u3 ай бұрын
Great Explanation Sir it helps me a lot , Their is no video on KZbin who can taught this topic clearly . Again Thanks soo much sir
@onlyc583 Жыл бұрын
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!
@baageledilepodisi2090 Жыл бұрын
i followed the instructions but run into "application error (0xc0150002)" on debugging
@vlados41979 ай бұрын
OH MY GOD THANKS YOU!!!!!!!! I LOVE YOU MY BROTHER ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
@anishkashyap5528 Жыл бұрын
Very nice content sir. It was getting very difficult for me to connect c++ and mysql but you helped me a lot 🥺🥺
@barok1383 Жыл бұрын
Thnak you very much, you solve my problem.
@adityarajamani932 жыл бұрын
wait this video only shows how to write data into sql....but how do i read info frm sql into c++?
@essersr-71382 жыл бұрын
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 !
@karl-ve2of2 жыл бұрын
Thanks for the guide.
@afif15972 жыл бұрын
Thanks for this tutorial :)
@mode-219 ай бұрын
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 ❤❤
@adil0332 Жыл бұрын
Can u do the same with vscode?
@siddharthjain425111 ай бұрын
bro did you got any idea i can do this in vscode
@viralvibes-shorts16 ай бұрын
What about newer versions of VSC? How do I access the project's properties there?
@elshodnematov131311 ай бұрын
cannot open source file mysql_connection.h and others, what should I do?
@nasjes3212 жыл бұрын
thank you!!!!
@HemaDarshiniSelvaraju Жыл бұрын
but you never tel us why we need to add all of those in that particular directory. How do you found that's what need to be done? Where is the source?
@vinayakonimani76288 ай бұрын
the docs, usually. When you do these a lot you start to understand things on your own. Also, the folders are named in a way that is self explanatory. Install a few library files for some languages and youll realize its *easier* than you anticipated it to be.
@mogneto88715 ай бұрын
Thank you.
@shahinabdullayev3340 Жыл бұрын
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.
@sierro48862 жыл бұрын
U are the best!
@Bob-Is-A-PotterNow2 жыл бұрын
I built a debug verson without problems but found that a required runtime dll (mysqlcppconn-9-vs14.dll) was not copied to the project output folder which resulted in a "not found" error. After verifying that the only problem was the missing dll, I copied it to the output folder and all was well. However, I couldn't figure out how to make the file copy a part of the build process. What I finally resorted to was a post-build entry to copy the file. Is there a better way to do this??? TIA
@BoostMyTool2 жыл бұрын
Maybe you did not link the application statically as I did. If you want to use the dll, you have several options: 1) add the dll to your project (as you did), 2) add the mysql folder to your system environment variables (this allows your application to find the dll during execution), 3) add the dll to any folder which is already added to the system environment variables. This video shows how to add mingw-w64 to the system environment variables: kzbin.info/www/bejne/eanTm2Opep2Spsk
@Bob-Is-A-PotterNow2 жыл бұрын
@@BoostMyTool Thank you for the multiple options. You're correct about not statically linking (which I suspected was the underlying cause). I'll explore the other suggestions to see which feels most efficient and perhaps "elegant." I'm aware that using dlls is completely inline with the design philosophy of the OS. My aging brain recalls that using dlls could result in smaller executables (and allow reuse of the dll code by other apps and processes) with a small impact on performance.
@zegarzegar1224 Жыл бұрын
@@Bob-Is-A-PotterNow Could you explain to me what the definition is between connecting to a database in debug and reales? In the sense of attaching files etc.
@zegarzegar1224 Жыл бұрын
Could you explain to me what the definition is between connecting to a database in debug and reales? In the sense of attaching files etc.@@BoostMyTool
@Bob-Is-A-PotterNow Жыл бұрын
@@zegarzegar1224 In debug mode your application will have access to step by step output from the database and will generally highlight errors or other issues. However, the debug processes will slow the overall performance of the database and require additional memory. In release mode speed will increase and the memory footprint decrease. HTH
@HNDaG2 жыл бұрын
Hello, your video was a great help for friends however not for me. Can you please give me pice of advice, after folowing all of your steps(including addind mysql server/bin to enviriment variables) i got few errors like LNK2001 external enviroment symvol __imp___std_init_once_begin_initialize file(mysqlcppconn-static.lib(my_malloc.obj) etc. What shoud i do?
@geovanygrant529810 ай бұрын
Did you resolve your issue?
@HNDaG10 ай бұрын
@@geovanygrant5298 if i remember correctly i was t able to found clean solution. At some point an dozen of different tutorial it randomly started to work. After that i decided that it s better to learn some other languages)
@aminestarkiller5 күн бұрын
Could not connect to server. Error message: Authentication plugin 'mysql_native_password' cannot be loaded: The specified module could not be found.
@Srayan0074 күн бұрын
Bro did you find any solution?
@aminestarkiller12 сағат бұрын
@@Srayan007 yes I gave the root of mysql a password
@viral_videos69694 ай бұрын
i did everything and i had this problem : Error LNK2001 unresolved external symbol "__declspec(dllimport) void __cdecl check(class std::map
@calixtodeveza27082 жыл бұрын
I get "LNK2019 unresolved external symbol mysqlcppconn-static.lib(charset.obj)" with vs2022 community v17.2, please any ideas?
@HNDaG2 жыл бұрын
I have nearly the same problem. Have you found a solution?
@anithaprasad8831 Жыл бұрын
I am getting error in the below code. "get_driver_instance" while running The error is "libcrypto-3-x64.dll was not found". How to solve it ?
@tobechukwueziolise1928 Жыл бұрын
try including "mysqlcppconn.lib" in Linker > input > additional dependencies and for your get_driver instance, make it "driver = sql::mysql::get_mysql_driver_instance();"
@paulohenriquesilveira52578 ай бұрын
the same, did you solve it?
@MostafaSharaby-s6n Жыл бұрын
at the end it give me that at console "Could not connect to server. Error message: Unable to connect to localhost" what is the issue here ? ?
@dolannimrod488210 ай бұрын
Mine too, did you ever figure out how to solve it?
@PeaceWalkerify2 жыл бұрын
Do you have a tutorial on how to do this with C# ?
@Hoptronics2 жыл бұрын
All that should probably work right like it's written in the pin ed comment. Then google the issues.
@ninjochoya60172 жыл бұрын
I get an error when running it at the con->setSchema("quickstartdb"); line. The error just says unhandle exception. Unhandled exception at 0x00007FFD1740CD29 in mySqlProject1.exe: Microsoft C++ exception: sql::SQLException at memory location 0x00000001000FF480.
@ninjochoya60172 жыл бұрын
I fixed it, I forgot to create the "quickstartdb" in the mysql command line before running it, now it works
@erjei96333 жыл бұрын
hello can we have the example program that you pasted in the last part? Thank you very much it would be a very big help :)
@BoostMyTool3 жыл бұрын
Hello, you can try any example. I will add the source code and the link of the source code in a comment
@SpringKerl2 жыл бұрын
hello thanks for the video! i have done evervthing as in the video but i get "LNK" Failures in the mysqlcppconn-static.lib Data. what could I do about it?
@BoostMyTool2 жыл бұрын
the error is not clear. maybe you did not add mysql to your system environment variables. this can fix your problem. try to follow this video: kzbin.info/www/bejne/noHQlatug7uSe6s
@SpringKerl2 жыл бұрын
@@BoostMyTool I had made a par mistakes i´m sorry, i´m a beginner Coder. Thank you for your great Tutorials!
@LeonardoN.2 жыл бұрын
@@SpringKerl how did you solve? I'm having the same problem.
@josephtristansubong7585 Жыл бұрын
is there a way to run it in debug configuration?
@chkarkamouhssine8715 Жыл бұрын
i did everything and i had this problem : Severity Code Description Project File Line Suppression State Error LNK2001 unresolved external symbol "__declspec(dllimport) void __cdecl check(class std::map const &)" (__imp_?check@@YAXAEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z) sql2 C:\Users\mehdi\Desktop\sql2\sql2\main.obj 1
@roscoebancroft27927 ай бұрын
Got the exact same issue - did you find a solution?
@فضائيات-خ7ذ Жыл бұрын
Is that work with C langage
@beytullahsengul2 жыл бұрын
thanks so much
@fjodorz3474Ай бұрын
important: IT MUST BE ON RELEASE MODE. i almost broke stuff till i rewatched the video
@n00btown Жыл бұрын
I've set this up properly, but i got two errors that there are .dlls missing. First is libssl-3-x64.dll and the second one is undlibcrypto-3-x64.dll. I don't know how to solve this problem. Maybe someone has an idea. Thanks for the video anyway
@joseandreparedesquispe4130 Жыл бұрын
Same here, hope anyone can solve this. EDIT: I found a solution which is what @Bob-Is-A-PotterNow did. I copied all dlls from the "MySQL Connector C++ 8.1/lib64" folder to the folder where the executable of my proyect is (in my case: "my_project/x64/Release/").
@yurokkj Жыл бұрын
not all heroes wear capes @@joseandreparedesquispe4130
@Морен-э7г10 ай бұрын
Thank you so much for that comment . I've been sitting there dumbfounded all day. Just, thank you so much❤❤❤❤❤❤@@joseandreparedesquispe4130
@michaelsilvers12606 ай бұрын
@@joseandreparedesquispe4130 God bless you. I will be very tired at work tomorrow considering I spent hours looking all over the internet for such a dumb simple soloution. MAY GOD BLESS YOU, YOUR FAMILY, EVEN YOUR DAMN DOG.
@vishnusaiviswajiththaroor1912 Жыл бұрын
Any idea how to do this in visual studio code ??
@siddharthjain425111 ай бұрын
bro did you got any idea i can do this in vscode
@alessandrosec7 ай бұрын
quien diría que este video me ayudaría tanto jajajja
@thomasweber80415 ай бұрын
Source code please
@didacemanirakiza10363 жыл бұрын
Good video. But I have question: I have a c program that get name, age, city, number and salary of user. I code in VS 2022. Can you give video about c program to connect it to Mysql? Thanks.
@emmettdja Жыл бұрын
i got linker errors after i did these steps
@emmettdja Жыл бұрын
fixed: STATIC_CONCPP was not added properly
@ajayjadhav9003 жыл бұрын
How to include sub-directories in Visual Studio? I have to include many header files, which are in different sub-directories. Is there a way in Visual Studio (I am using 2013 edition) to set one include path that Visual Studio will search also the sub-directories for header files? My Project is in C/C++. Add the "base folder" to the project (project properties -> Configuration Properties -> C/C++ -> Additional Include Directories, "additional include directories") I have tried the above option but it is not possible for me to add each and every directory followed by a semicolon. I have total 60 + different C C++ sub-directories
@anho72662 жыл бұрын
I got Libcrypto-1_1-x64.dll missing error
@anho72662 жыл бұрын
Oh i think i was try to builld it in x86
@BoostMyTool2 жыл бұрын
@@anho7266 the dll is in the bin folder of mysql. you should add the bin folder of mysql to your system envionment variables (see this video: kzbin.info/www/bejne/nZi1oJt7g6eam80 )
@ai_serf Жыл бұрын
using xampp I couldn't get environment vars to properly load some dlls. i copied over libcrypto-1_1-x64.dll and libssl-1_1-x64.dll from xampp/php to my c++ project. seems to work so far.
@rino19ny2 жыл бұрын
VS 2022 Community Edition MySQL Connector/C++ MySQL container in Docker i can connect to mysql server from command prompt (Windows 10, 21H2). followed your video to the letter and got the first two errors: Severity Code Description Project File Line Suppression State line 298 Warning C26495 Variable 'sql::Variant::variant' is uninitialized. Always initialize a member variable (type.6). MySQLProject1 C:\Users\user1\Documents\mysql-connector-c++-8.0.29-winx64\include\jdbc\cppconn\variant.h line 1 Error LNK2001 unresolved external symbol "__declspec(dllimport) void __cdecl check(class std::basic_string const &)" (__imp_?check@@YAXAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) MySQLProject1 C:\Users\user1\source epos\MySQLProject1\MySQLProject1\main.obj Error LNK2001 unresolved external symbol "__declspec(dllimport) void __cdecl check(class std::map const &)" (__imp_?check@@YAXAEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@U?$less@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z) MySQLProject1 C:\Users\user1\source epos\MySQLProject1\MySQLProject1\main.obj 1
@PatPat-qd4nr2 жыл бұрын
Hi @BoostMyTool ! It says libssl-1_1-x64.dll and libcrypto-1_1-x64.dll missing for me. If i copy the dll-s next to the exe it is fine. I saw the related .lib , can I static link it somehow? I could not managed it. I have bad experience with dll-s, it can be replaced, this is why i ask. Thanks.
@BoostMyTool2 жыл бұрын
Hello, I did not have this error because I added mysql to the system environment variables (you can see this video to know how: kzbin.info/www/bejne/nZi1oJt7g6eam80 ). When you add mysql to the system environment variables, your C/C++ application will be able to access the dll files which are available in the bin filder of mysql. I don't know how to link statically. Anyway, adding the dll files to your exe is a valid option that is done by many applications