Connect to SQL Server using C++ GUI Windows Form in Visual Studio 2022 (C++ Database Connection)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and welcome guys to this interesting session in this session we are going to see how we can connect C++ GUI application to SQL server and we will do insert and select operations as promised I'm bringing you this video today yesterday or my previous session I added one video how to create mod GUI with C++ and visual studio if you miss that session I will give the video link on description as well as the I button please check it out also in the previous session you can find out the download source code link and today session also after complet completing the session I'm going to give the link in the video description you can check it out guys before starting the session I have a deep request in last 28 days you can see there are new viewer 18.3k and there are returning viewer 3.7k so please those who are new new here please please please do subscribe to my channel it will encourage me a lot it will not cost you a single penny but really your subs my subscription count will encourage me a lot so please do subscribe and if you ended up liking this video give me a like and share this video with your friend let's get started so in my previous sessions you can see project CP P CPP app I have created okay just do wait if you miss that session I strongly recommend also in the video description also I will give the link and the recommend tutorial you can check it out okay let it load our application okay this is all the new I have added now this is the main form we have added right we have email ID Mobile number and full name now I'm going to do the database operation how I can do I'm not opening any SQL Server SS SMS here also I'm directly linking my database this is my server so here I'm going to create a table this is a database name is called ydb or YouTube DB I created where let's add a table here add new table I no need of this so I will directly write the query here okay crear table let's say I'm giving user record now if I execute this query how I can execute okay let's close this right click new query and here I'm pasting this one and running command complete successfully here go to here and click on refresh so you can find user record table okay check this also you can directly copy select start from user record run this that is a blank record okay you can find table is coming now my task is to store This Record into my table for that we need to go to our HED file which is our form. H just double click on the submit button in my previous session I saw how we can do validation in this part we are going to submit so before that guys forget about the forgive about the background noise I can write using Nam space s down colon Colum data. colon colon SQL client right next thing is we have ADD our name space next we need to go to our submit button here we can write our code how we can write our code in this else part where I'm doing the data submit successfully I can do like this I can put a TR catch okay okay in this section I can put SQL next is our data save successfully part right so what I did here let's okay I declared a string a SQL con string and the database name the server name database name and user ID password okay which is I got from here in the server so if you click on this and right click and go to properties so you can see the connection string right I'm directly copy paste connection string and put it here change the password next is I declare a SQL connection con here added the connection string next connection. open I added declare a SQL query where I'm going to write my insert statement n next is SQL command add adding the SQL query just as like a ado.net then execute non query and connection. close next is the message here I can write like this insert into my table name is record Valu like this so first name will be first thing is full name email ID Mobile number so this to txt name. text same thing I can do copy paste for next part email ID Mobile number so here will be txt email and here will be txt mobile number right that say successfully done after this I will be calling the reset so it will be resetting my form now run the application after this session I'm going to upload this to Google Drive and give the link to download you can check it out so build isn't working so let's give you can see in my table there is no record till now so let's add a record click on submit data submitted successfully okay it got clean now run the query data is coming so here I can add submit successfully it is is coming now so in this way we can insert record to SQL server using C++ GUI application now I'm going to add a new button here which will be giving me search so how I can do this I will add a button here it will search from [Music] my full name so I'll be doing like this search BTN search double click to generate the event or listener okay adding a TR cage so any exception we can catch okay here I'm adding this one what is string SQL connection string same thing next is I'm declaring a connection Quil connection adding that connection string part now I'm declaring a SQL query where I'm going to write my select statement next each SQL command passing the SQL query and connection next connection is open declaring a SQL data Reader Dr and command. execute reader here I can give like this for your name like here name right so go to main form. H here write like this this will be this extend to txt name dot sorry the text now we need to check if data is present or not here I'm checking if Dr SQL read just I'm just assigning the message to like this message result full name equal to full name email ID Mobile number so I'll be giving email ID and mobile number number right now I will be else dr. close same thing I'm going to keep here also okay that no a found so here I can give the result it will display me the result now let's search let's add one more name Alex mobile number submit let's search with my name which added fast something gone wrong invalid column name name okay here will be full name right the now name is engine like so I give an Alex also searching from the DV so in this way we can insert and select to our database guys I hope you like this video If you do give me a like and share your comments and suggestion in the comment box and please don't forget to subscribe thank you very much
Info
Channel: Biswa Ranjan
Views: 336
Rating: undefined out of 5
Keywords: c++, windows forms application, visual c++, c++ tutorial, c++ programming, learn c++, C++ with Database, C++ with SQL Server, C++ and SQL Server, C++ Database Connection, C++ and Database, clr/c++ windows forms, windows desktop, visual c++ tutorial, c++ gui, create a program in c++ with gui, c++ gui tutorial, c++ windows form tutorial, vs 2022, winforms, c++ winforms, windows forms c++ visual studio 2022, C++ for beginners, C++ Development, C Plus Plus Development
Id: W0GS4jyfHlM
Channel Id: undefined
Length: 12min 5sec (725 seconds)
Published: Fri Nov 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.