Це відео не доступне.
Перепрошуємо.
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...
#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
I need code or video about c program. I see this is c++. Thanks
@@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?
thank you
This is the ONLY video that helped me, there isn't much info about C++ on UA-cam, Thanks ALOT!
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!
I LOVE YOU!!!!
The only one mornal guide that i found during the whole day
i followed the instructions but run into "application error (0xc0150002)" on debugging
Thanks pal. You are the only one who can explain me how to include mySQL to cpp code)
Thank very very very much man, I don't know what I would have done without your guide, really thanks!
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!
wait this video only shows how to write data into sql....but how do i read info frm sql into c++?
What about newer versions of VSC? How do I access the project's properties there?
Very nice content sir. It was getting very difficult for me to connect c++ and mysql but you helped me a lot 🥺🥺
cannot open source file mysql_connection.h and others, what should I do?
Thanks for the tutorial! You're a life saver.
Thanks so much dude, you really saved me there. Quick and simple.
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 !
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
❤❤
great! it worked for me
Thanks a lot
It worked! thank you very much!
OH MY GOD THANKS YOU!!!!!!!! I LOVE YOU MY BROTHER ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
Can u do the same with vscode?
bro did you got any idea i can do this in vscode
Thnak you very much, you solve my problem.
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.
Thanks for this tutorial :)
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
Got the exact same issue - did you find a solution?
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?
Did you resolve your issue?
@@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)
Thanks for the guide.
Thank you.
thank you!!!!
U are the best!
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?
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.
I get "LNK2019 unresolved external symbol mysqlcppconn-static.lib(charset.obj)" with vs2022 community v17.2, please any ideas?
I have nearly the same problem. Have you found a solution?
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
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
@@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.
@@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.
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
@@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
is there a way to run it in debug configuration?
Source code please
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.
I fixed it, I forgot to create the "quickstartdb" in the mysql command line before running it, now it works
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 :)
Hello, you can try any example. I will add the source code and the link of the source code in a comment
quien diría que este video me ayudaría tanto jajajja
thanks so much
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.
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 ? ?
Mine too, did you ever figure out how to solve it?
Is that work with C langage
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
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 ?
try including "mysqlcppconn.lib" in Linker > input > additional dependencies and for your get_driver instance, make it "driver = sql::mysql::get_mysql_driver_instance();"
the same, did you solve it?
Do you have a tutorial on how to do this with C# ?
All that should probably work right like it's written in the pin ed comment. Then google the issues.
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?
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
@@BoostMyTool I had made a par mistakes i´m sorry, i´m a beginner Coder. Thank you for your great Tutorials!
@@SpringKerl how did you solve? I'm having the same problem.
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
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/").
not all heroes wear capes @@joseandreparedesquispe4130
Thank you so much for that comment . I've been sitting there dumbfounded all day. Just, thank you so much❤❤❤❤❤❤@@joseandreparedesquispe4130
@@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.
Any idea how to do this in visual studio code ??
bro did you got any idea i can do this in vscode
i got linker errors after i did these steps
fixed: STATIC_CONCPP was not added properly
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.
I got Libcrypto-1_1-x64.dll missing error
Oh i think i was try to builld it in x86
@@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 )
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
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.
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