Complete CRUD in C# With SQL | Insert Delete Update Search in SQL using ConnectionString in C#

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Thanks sir. I have tried and finally succeed by following this tutorial.

👍︎︎ 1 👤︎︎ u/FastCookRecipe 📅︎︎ Dec 02 2020 🗫︎ replies
Captions
hello viewers welcome to programming geek i'm here with a new tutorial that is complete crude version using cshop with amaz sql server [Music] this is complete currency here with ask tutorial for beginner this is my sql server server names catalog hyphen as well login as a password is exclusive authentication password as the database folder new database now i'm going to creating a database and a table in the sql server my database name is program programming tutorial db click on ok yes my database is created you can see programming tutorial review folder there is no table yet this i just create this uh database now i'm going to create a new new table table name is a first column is product id and table name i just named this table as product info underscore tab okay yes the scatter table is created product id is integer type data type is integer and this is primary key product id item name and parker and design product design is and worker 250 250 because the design is a bit long color and worker 50 50 means 50 character and started daytime daytime okay now save yes replace this table folder now right click and replace the table folder yes you can see the table is added product info underscore tab okay and i'm going to see records there's no records yet now [Music] in this programming tutorial folder i'm gonna create an uh windows form application new project windows from application uh select the location location sd programming tutorial folder select the programming tutorial folder open okay now name the project i just named it as a crude underscore in c sharp oh hash is not allowed so all right sharp okay our application is created now design this form uh with the level control text box and button control with the grid view daily grid view change the back color of this form okay now go to the toolbox and add a level yes this level control i will use as the title of this form okay font size 18 font bold true and change the text and color level control color is white and text is [Music] crude tutorial in c-sharp okay now go to the toolbox again and just [Music] add level control this level control uses product id color button pace and font size 10 12 okay to go up on board true and text is change the text text is product id okay now add a text box control from the toolbox just drag the text box and drop it in the windows from application go to the property and change the font size font size is 10 and resize this text box just copy the product id level and text box in the stack list name is techniques one and the second one is textbooks two third one is checklist three and second text box uh i mean texas two for item name third one is for uh design and the combo box combo box uh font size is 10 com works for color uh level item name and design [Music] and level control for color [Music] okay [Music] color now add the color item and combo box item okay red color is red green blue white and black just click on okay okay it's added now add button control [Music] this button control i'll use to insert records in the sql server database table so text is insert and change the font size font size is 10 for font bold true four colors button piece and the back color change the back color of this button yes now it's looking nice go to the toolbox and add a data grid view control yes this is the dedicated boot controller used to load to display records from sql server database to daily grid view okay double click to go to the click event yes this is the button on click event i mean insert click event in this click event i will write to code to insert records now add connection with the connect to the sql server database server name is catalog hyphen sphere and authentication and the skills of authentication is an image and password description authentication password and database my database name is programming tutorial db click on ok yes expand the database action on the table yes programming tutorial db [Music] you can see it's added in the server explorer now connect with the sql server to connect with sql server you should use sql connection to use the sql connection you must add namespaces in system.data.sql client you can write it manually or you can just click on using system data dot ask well client okay it's and the name space is added now right click on the database go to the property and the double click to copy select and copy the connection string and face in the double quotation okay the connection string is added now it's connected to the sql server database scroll command mysql command is to select uh to insert records in the sql server database table so um that's called command command equal to new sql command my command is insert into product info underscore tab this is my sql server database table you can see in the left side the server explorer database programming tutorial db okay values values are first one is for product you can see and the value will get from the textbooks one and this is not an item name textbooks 2 and design textbox 3d color text box for combo box one okay now values textbox one dot text product id this is integer type so convert it to integer integer dot first exon dot text comma and just copy with the syntax and just paste this is uh i have four column so this is techniques one and textbooks two for item name this is a string so no need to convert it now to integer and this is for text box three design and finally uh this is uh not actually this is combo box color from combo box so combo box one text okay then insert it insert that is getdate okay now initialize the connection string con and command dot execute non-query execute none could be used to insert delete or update records in the sql server database using c sharpens file in this form okay now finally it will display message message box dot show successfully inserted okay now open the connection con dot open and finally after completing the operation just close the connection con dot close [Music] okay let's debug product id101 item name computer design full set color black insert oh login field for user s i have to check the connection listing let's check the connection string you can see user id so it's fine but password is a start so you should put your uh database authentication password okay now debug again usually i keep the error so that beginners can understand how to solve error and how to face error okay color black insert yes successfully inserted but it's not displaying the data view to display in the data grid view you can see the records is inserted but not displaying the data git view so to display in the data git view i'm gonna add a method first of all just put the sql connection outside of the bar click event so that you can use this connection listing in every every click event or a method in space okay this method is board mine data scroll command command equal to i can see uh i i just put the connection string out of the event so that i can use it in the uh air method [Music] so come on commander continue sql command select star from product input tab con corners connection listing i just initialized and then asked that adapter sd equal to new sql data adapter command and then dt bill dd equal to new data table [Music] sd dot fill dd okay finally data grid view one dot data source equal to dt okay and now call the math in the button click event and form load event as well so that you can get the result at the debugging the run time okay now you can see it's displaying the records inserted records in the data grid view and i'm gonna insert one more records product id 102 item name laptop design dell and 21 inches and then color [Music] this is 45 color is green white black yes black insert successfully inserted and the result also displaying the data give me instantly okay now copy this button and face this button i will use to update records in sql server using c7 spawn application using connection string text is update event double click uh the click event now i'm going to write code to update record next conservatives table conduct open sql command con is my sql connection what i fail my foot outside of the event and this page okay now command command equal to an sql command initialize the connection string con and in this pattern click event i will update the records in the sql server database table so my command is update product info underscore tab this is the table name product info tab set item name product id is primary key so you cannot update a primary key you can update all the records uh each records based on product id so item name equal to textbox2.txt [Music] yes [Music] okay uh comma and text box three dot text for design design equal to textbook3.txt yes comma and color color equal to for the syntax single quotation then double quotation then plus sign and combobox1.txt yes then right click and go to the design now i'm gonna add one more column for update or date adding a column for updated [Music] okay updated date time save refresh this page in the server explorer table okay [Music] update date equal to get date get date means uh the date will get from the from your machine from your pc desktop [Music] higher product id all the records update based on product id which product you will select in the textbox one dot text okay product id equal to integer dot first product id is integer to paragraph integer so you should convert to integer into the dotted titles one dot text finally command dot execute non-query after completing the operation contour close and it will display the message message box dot show successfully update it okay now debug we should call the bind data so that you can get results instantly the data grid view okay now dell 21 in score i5 one zero two and i will update records one zero two product id uh laptop dell uh 21 institute and 18 in c and color is white black to white update oh yes invalid column name design this is a spelling mistake uh let's check the design [Music] oh sorry h n okay now be back again and the other column is uh okay now debug again [Music] 102 item name laptop design [Music] dell 18 inches white update oh conversion fail convert date time from characteristic oh sorry let's check the updated okay update get it uh remove the single quotation single quotation used to uh you used as cheated as a string so get it is that time okay now the back again del 18 in c2 uh so that left on desktop dell 18 inches to 19 inches and color white to black yes just click on update successfully updated yes you can see update date also added using date configure to insert updated manual then i'm gonna add a datum figure to insert to uh insert update date manually in that case [Music] um add a date and figure control and a level control and the text of this level is date and control is datum figure the name of the datum figure control is datum figure one you can see in the property into dating figure one format short and font size 10 on bold true okay now you can uh food dating wicket instead of get date get it is current date and identification you will select the dating figure one it will edit the updated datetime.first datum figure one dot text okay now debug [Music] yes now this is uh 26 september 102 item name desktop design desktop cpu design dell full set [Music] color white black to white and i just put it in 24 september successfully updated let's check yes 24th september is edited okay now copy the button control this button control i'll use to delete records from the sql server database based on product id okay [Music] now conduct open ascual command this command i'll use to delete record so skill command command equal to new sql command my command is a delete product info tab ir product id equal to uh product id yes product id equal to text box one uh product id is integer type so uh convert it into the integer dot first techniques one dot text yes now command dot execute non-query conduct close finally after completing the delete operation you'll display the message message.show successfully deleted okay [Music] now bind data called the method bind data so that you can get result instantly for the records of id102 delete oh sorry connection has not been initialized i have to initialize the connection string so in the sql command just initialize the connection comma and con okay now the back again [Music] yes [Music] oh a drain for twisting was not in a correct format you should add a if condition so that you cannot get this error so if triggers one dot text not equal to exclamation mark equal means not equal to blank then then it will execute this operation if it the textbox one is blank then it will display a message that foot product id message box dot show put product id okay and now debug again delete you can see food product id and displaying that so food productivity 102 then delete first problem invalid product id oh sorry [Music] i usually give to error so that beginners can understand how to solve this error okay now everything is fine delete successfully deleted okay now i'm gonna insert uh one more records 102 name desktop dell 17c green insert see that column name or number separate value does not match table definition so my table column i later i have added updated but here's only insert insert date so i have to add update date column and the sql command get date updated finish initially get it or you can keep it as now [Music] 102 item name desktop design full set [Music] color black yes now it's inserted successfully with insert date and update the default update date results now item name cpu green update you can see it's updated updated okay delete is uh confidential if you delete a record you cannot reback this record so add a confirm message before delay before performing delete operation so if message box dot show are you sure to delete and delete record message box button dot yes no equal to dialog result dot yes [Music] okay if dialog result yes i mean if you after confirm message if you select yes if you click yes it will execute the operation like 102 delete are you sure to delete if you click no it will not deleted if you click yes then it will be deleted yes it's deleted [Music] okay start position center screen so that it will um display at run time in the center of this screen delete are you sure to delete no okay now it's fine charts based on product id now i'm gonna show how to charge records based on product id the result will display in the data grid view with that this button click event okay now text is charts okay double click to go to the click event yes uh i just uh copy the code uh to reducing time this is uh on the displaying records on this method i have alright to download all the records in the database view and this button click event i'll use to load record based on product id a specific product id okay just add higher country and clause higher protected equal to integer.first textbox1.txt okay now everything is same just debug yes one zero two i just first of all i am just inserting record only to monitor design dell color black successfully inserted 103 mouse design dell red and successfully inserted and the fourth record is calculator green successfully inserted there's a four record and i can see if i charge one through four it will display one three four if i charge from there two and displaying 102 record 3 displaying 103. okay if you want to delete successfully delete you can see 103 is not in the list and only three records on zero one two and four [Music] you
Info
Channel: ProgrammingGeek
Views: 26,925
Rating: undefined out of 5
Keywords: programminggeek, crud in c# with sql, crud in c# with sql server, c# tutorial, insert update delete in c# with sql server, crud in c#.net, crud in c#, insert update delete and search in sql server using c#, insert in sql using c#, update in sql using c#, delete in sql c#, search data from sql using c#, insert, update, delete, view, visual studio code, crud c#, virul, c# crud windows forms, c# crud sql server, c# crud tutorial
Id: 4bQfxbSj4tg
Channel Id: undefined
Length: 27min 2sec (1622 seconds)
Published: Sun Sep 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.