Це відео не доступне.
Перепрошуємо.

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

Поділитися
Вставка
  • Опубліковано 30 гру 2021
  • 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.
    **********************
    Source code in the first comment or at this link: docs.microsoft... .
    ***********************************
    🔥 Complete Udemy Courses :
    Build E-commerce Web Application using ASP.NET Core : www.udemy.com/...
    Build E-commerce Web API using ASP.NET Core : www.udemy.com/...
    Build E-commerce Web Application using React JS : www.udemy.com/...
    ⬇️ Free Document Proofreading ⬇️
    ► Grammarly : grammarly.go2c...

КОМЕНТАРІ • 91

  • @BoostMyTool
    @BoostMyTool  2 роки тому +15

    #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

    • @didacemanirakiza1036
      @didacemanirakiza1036 2 роки тому

      I need code or video about c program. I see this is c++. Thanks

    • @Bob-Is-A-PotterNow
      @Bob-Is-A-PotterNow 2 роки тому

      @@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?

    • @buddgaf1304
      @buddgaf1304 2 роки тому

      thank you

  • @geraldmacherechedze5197
    @geraldmacherechedze5197 Рік тому +4

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

  • @Bob-Is-A-PotterNow
    @Bob-Is-A-PotterNow 2 роки тому +10

    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
    @yegorkliushin7705 Рік тому +2

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

  • @baageledilepodisi2090
    @baageledilepodisi2090 Рік тому +4

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

  • @aleksandrguz6508
    @aleksandrguz6508 Рік тому

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

  • @nevell6069
    @nevell6069 2 роки тому +1

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

  • @onlyc583
    @onlyc583 9 місяців тому

    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!

  • @adityarajamani93
    @adityarajamani93 2 роки тому +2

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

  • @footballvids902
    @footballvids902 Місяць тому

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

  • @anishkashyap5528
    @anishkashyap5528 6 місяців тому

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

  • @elshodnematov1313
    @elshodnematov1313 6 місяців тому +1

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

  • @sudarson25
    @sudarson25 7 місяців тому

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

  • @Auditor1337
    @Auditor1337 Рік тому

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

  • @essersr-7138
    @essersr-7138 Рік тому

    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 !

  • @mode-21
    @mode-21 4 місяці тому

    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
    ❤❤

  • @nguyenxuanthong3179
    @nguyenxuanthong3179 9 місяців тому

    great! it worked for me
    Thanks a lot

  • @Evans1997
    @Evans1997 Рік тому

    It worked! thank you very much!

  • @vlados4197
    @vlados4197 4 місяці тому

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

  • @adil0332
    @adil0332 8 місяців тому +3

    Can u do the same with vscode?

    • @siddharthjain4251
      @siddharthjain4251 6 місяців тому

      bro did you got any idea i can do this in vscode

  • @barok1383
    @barok1383 9 місяців тому

    Thnak you very much, you solve my problem.

  • @shahinabdullayev3340
    @shahinabdullayev3340 8 місяців тому

    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.

  • @afif1597
    @afif1597 2 роки тому

    Thanks for this tutorial :)

  • @chkarkamouhssine8715
    @chkarkamouhssine8715 Рік тому +2

    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

    • @roscoebancroft2792
      @roscoebancroft2792 2 місяці тому

      Got the exact same issue - did you find a solution?

  • @HNDaG
    @HNDaG 2 роки тому +3

    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?

    • @geovanygrant5298
      @geovanygrant5298 5 місяців тому

      Did you resolve your issue?

    • @HNDaG
      @HNDaG 5 місяців тому

      @@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)

  • @karl-ve2of
    @karl-ve2of Рік тому

    Thanks for the guide.

  • @mogneto8871
    @mogneto8871 9 днів тому

    Thank you.

  • @nasjes321
    @nasjes321 Рік тому +1

    thank you!!!!

  • @sierro4886
    @sierro4886 Рік тому

    U are the best!

  • @HemaDarshiniSelvaraju
    @HemaDarshiniSelvaraju Рік тому +1

    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?

    • @vinayakonimani7628
      @vinayakonimani7628 3 місяці тому

      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.

  • @calixtodeveza2708
    @calixtodeveza2708 2 роки тому +1

    I get "LNK2019 unresolved external symbol mysqlcppconn-static.lib(charset.obj)" with vs2022 community v17.2, please any ideas?

    • @HNDaG
      @HNDaG 2 роки тому

      I have nearly the same problem. Have you found a solution?

  • @Bob-Is-A-PotterNow
    @Bob-Is-A-PotterNow 2 роки тому +2

    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

    • @BoostMyTool
      @BoostMyTool  2 роки тому

      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: ua-cam.com/video/Cxpj0sE8_pg/v-deo.html

    • @Bob-Is-A-PotterNow
      @Bob-Is-A-PotterNow 2 роки тому

      @@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
      @zegarzegar1224 10 місяців тому

      @@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
      @zegarzegar1224 10 місяців тому

      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
      @Bob-Is-A-PotterNow 10 місяців тому

      @@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

  • @josephtristansubong7585
    @josephtristansubong7585 Рік тому

    is there a way to run it in debug configuration?

  • @thomasweber8041
    @thomasweber8041 18 днів тому

    Source code please

  • @ninjochoya6017
    @ninjochoya6017 Рік тому

    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.

    • @ninjochoya6017
      @ninjochoya6017 Рік тому

      I fixed it, I forgot to create the "quickstartdb" in the mysql command line before running it, now it works

  • @erjei9633
    @erjei9633 2 роки тому

    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 :)

    • @BoostMyTool
      @BoostMyTool  2 роки тому +1

      Hello, you can try any example. I will add the source code and the link of the source code in a comment

  • @alessandrosec
    @alessandrosec Місяць тому

    quien diría que este video me ayudaría tanto jajajja

  • @beytullahsengul
    @beytullahsengul 2 роки тому

    thanks so much

  • @didacemanirakiza1036
    @didacemanirakiza1036 2 роки тому

    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.

  • @user-wx5om7co1y
    @user-wx5om7co1y 8 місяців тому

    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 ? ?

    • @dolannimrod4882
      @dolannimrod4882 5 місяців тому

      Mine too, did you ever figure out how to solve it?

  • @user-lw1by1ir8l
    @user-lw1by1ir8l 7 місяців тому

    Is that work with C langage

  • @ajayjadhav900
    @ajayjadhav900 2 роки тому

    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

  • @anithaprasad8831
    @anithaprasad8831 10 місяців тому

    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
      @tobechukwueziolise1928 10 місяців тому

      try including "mysqlcppconn.lib" in Linker > input > additional dependencies and for your get_driver instance, make it "driver = sql::mysql::get_mysql_driver_instance();"

    • @paulohenriquesilveira5257
      @paulohenriquesilveira5257 3 місяці тому

      the same, did you solve it?

  • @PeaceWalkerify
    @PeaceWalkerify Рік тому

    Do you have a tutorial on how to do this with C# ?

    • @Hoptronics
      @Hoptronics Рік тому +1

      All that should probably work right like it's written in the pin ed comment. Then google the issues.

  • @SpringKerl
    @SpringKerl 2 роки тому

    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?

    • @BoostMyTool
      @BoostMyTool  2 роки тому

      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: ua-cam.com/video/hPmdx8NV_EI/v-deo.html

    • @SpringKerl
      @SpringKerl 2 роки тому

      @@BoostMyTool I had made a par mistakes i´m sorry, i´m a beginner Coder. Thank you for your great Tutorials!

    • @LeonardoN.
      @LeonardoN. 2 роки тому

      @@SpringKerl how did you solve? I'm having the same problem.

  • @n00btown
    @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
      @joseandreparedesquispe4130 Рік тому +4

      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
      @yurokkj 11 місяців тому

      not all heroes wear capes @@joseandreparedesquispe4130

    • @user-qv7vd7qz2z
      @user-qv7vd7qz2z 4 місяці тому

      Thank you so much for that comment . I've been sitting there dumbfounded all day. Just, thank you so much❤❤❤❤❤❤@@joseandreparedesquispe4130

    • @michaelsilvers1260
      @michaelsilvers1260 Місяць тому

      @@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 ??

    • @siddharthjain4251
      @siddharthjain4251 6 місяців тому

      bro did you got any idea i can do this in vscode

  • @emmettdja
    @emmettdja Рік тому

    i got linker errors after i did these steps

    • @emmettdja
      @emmettdja Рік тому +2

      fixed: STATIC_CONCPP was not added properly

  • @ai_serf
    @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.

  • @anho7266
    @anho7266 2 роки тому +1

    I got Libcrypto-1_1-x64.dll missing error

    • @anho7266
      @anho7266 2 роки тому

      Oh i think i was try to builld it in x86

    • @BoostMyTool
      @BoostMyTool  2 роки тому +1

      @@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: ua-cam.com/video/ggRohENBgek/v-deo.html )

  • @rino19ny
    @rino19ny 2 роки тому

    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-qd4nr
    @PatPat-qd4nr 2 роки тому +1

    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.

    • @BoostMyTool
      @BoostMyTool  2 роки тому +1

      Hello, I did not have this error because I added mysql to the system environment variables (you can see this video to know how: ua-cam.com/video/ggRohENBgek/v-deo.html ). 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