CRUD in C# With SQL Using Linq | Insert Delete Update Search in SQL in C# Linq to SQL Class

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello viewers welcome to programming gig i'm here with a new tutorial that is complete crude operation using c sharp with sql using link hue [Music] this is my sql server server name is catalog hyphen aspier start microsoft sql server management studio okay now for task server authentication password then connect okay expand the database folder as my database my database name is and i'm gonna create a database database name just name the database programming tutorial db click on ok ok now the database is created you can see expand the table folder there is no table yet now i'm going to create a new table column name is product id this is integer type and primary key item name and worker design design is and worker 150 150 characters after 150 character color is 50 okay now insert date inside it is the date time data type is date time and update date also data type date time [Music] finally expiry date product expiry date this data type also date time now just save namely table my table name is product info underscore tab click on ok yes the table is created now just delete this table folder and you can see the table is added now start visual studio in client pc okay now click on new project with c of windows the application will store in the g programming tutorial folder and the name the application is screwed tutorial using link you click on ok yes the application is created now design this form with the level text box and the combo box the temperature control the start position is center screen of the form back color is uh okay blue palette now get the toolbox and expand the whole windows form add a level control just a drag and drop in the windows form application this label controller used as the title of this form so font size is 18 and fontboard true for color i mean font color color is button paste says the text text is a crew tutorial using link you okay now add a glue box country yes in this group box i will add text box combo box dating figure and level control okay now at level control [Music] change the text text is product id [Music] and font size tan board true and for colors button piece okay now it's looking nice add a text box control from the tool box yes place this tag box beside of product id and change the font size of this text box font size is 10 okay now just copy the level control and the text box control and for dia product item name and design okay second text box and button level control is for item name and third level is for design and copy the label control and paste for color and expired it change the text of this level control this is for color and and this one for expiry date okay color is a specific color so add a combo box control yes and change the font size of this combo box come with font size also 10 and add a 10 figure control for expiry date data figure control name is creating figure 1 change the font size font size is 10 and 1 bold true format format is the default is long make it short yes now this is short format date time okay now at button control this button control i will use to insert records in the sql server database table using link you okay text is insert font font size 10 on both true and for colors button paste back color back color is violet okay now add a delegate view control to display the records to load the right inserted records in the database view control okay now go to the button click event here i will write code to insert records uh in sql server database in that case i'm gonna adding a link you file add new item okay now link you to sql classes select link you to sql classes data class1.dbml renamed this file dbml file and this is programming class dot dbml just click on it yes it's edited okay programming cluster dvm is added now go to the server explorer data can right click data connection add connection server name my server name is catalog hyphen beer and authentication is asked authentication username s and password just cut server authentication password select the database my database name is programming tutorial db select the database and click on ok yes it's connected with the visual studio and displaying the server explorer just drag the product info tab and drop it in there programming class.dbml okay now just click on yes yes it's edit now i'm gonna write code first of all i have to connect with the link your file with css my cs file program form 1.cs file in that case write programming class data context db equal to neoprogramming class data context okay now i'm going to write insert track insert code to insert records in the specifications table first of all i'm gonna declaring some variable variable is product id integer product id equal to int dot parse textbooks one dot text what i added one dot test and the string uh item name [Music] item name equal to uh this is listing type variable item name equal to text box two dot text and design from texas3.x okay color from combobox1.txt [Music] and finally expiry date expiry date is date time so and declare the variable date time date time expiry date day equal to date time dot parse [Music] return picker one dot text no you should convert it to date time date time dot pass data one dot text okay now variable declaring is done let's check product id item name color expiry date add comment box item to it unbox item just write red green blue white what uh your color just click on ok ok let's edit now go to the click event yes here now i'm going to write code to insert records in the especially database table using link you in that case equal my table name my table name is product info underscore tab you can see beside of this uh in the server explorer product info underscore tab product id product id equal to product id variable product id item you can use text box instead of variable i just uh declaring variable and use this variable so that you can understand how to declare variable and how to use this variable also okay design design and color equal to color from chromebooks 1. text color and then expiry date expiry date equal to expired it okay now finally db division database db dot product info underscore tabs dot insert on submit sd sd okay now dvd submits the submission is used to insert update or delete records using link you finally uh after completing the after executing the operation then it will display the message message box dot show successfully inserted okay let's debug now first of all now i'm gonna add a method to load result to display result instantly in data grid in that case a method to load data in data grid void load data [Music] and now i'm going to write code to load all the records in the data grid view so first you're going to promise individual product info underscore tab select s just detect it beyond the data choose equal to st okay now call this method in the button click event yes let's debug yes it's debugging product id 101 item name laptop design dell core i 5 color select a color from combox black expiry date for the date yes now just click on uh actually 2012 22 yes successfully insert you can see but inserted update date is not inserted because i didn't mention this column in button click even so okay now add a insert it insert that equal to date time dot now i mean current date date time dot now okay [Music] back again yes you can see the result is not displaying in the dating gate view to display the result that i give you at run time first time so just call this method in the form load event now the back again yes productivity item name design color is displaying at run time now i'm gonna insert one more records product id 102 item in a mouse design dell and color red expiry date is 13 september successfully added and there is displaying the resultant stance in the td grid view [Music] with insert date and expiry date okay okay now go to the form design and just copy this button and uh first i'm just adding one more button to far from update operation text is update okay now go to the button click event [Music] yes in this clip i'll write code to update records based on product id from textbox one okay now embarrassed equal to from fastbreak from s in db dot product in for underscore tab irs dot product id equal to equal to integer dot first noted that you must use double equal in link you and the dot first type respond select s after the break dot past okay okay now st dot item name item name will update based on product default product that you select it will update based on that product because product is primary key column student item name equal to i just copy the variable and paste it in update button click event so that i can use this variable instead of writing the full text box name okay now you can see st dot item name equal to item item name we will get from the text box to dot text okay then i still have design design from the text theory design and color from combobox1 so color and finally exported it st dot expiry date equal to dates the temperature won the text finally db dot submit you must add submitting video submissions without deletion you cannot get the result okay till now finally it will display the message message.successfully updated okay now debug [Music] put productivity102 item name mouse okay fine mouse left off [Music] right now it's a mouse now i'm gonna update you it will be uh mouse left off and design is hp delta hp and color red to white and expiry date 10th october 2020 just click on update successfully updated and the result also is displaying the data grid instantly but updated not showing to because uh i have not mentioned updated now add everyday sd dot update equal to datetime.now start okay now i want you to item name mouse mouse lefty to mouse hp to dell and white white okay now expiry date now see that there's not return now click ok yes successfully updated and updated also displaying in there as well server from sql server to daily review okay now i'm gonna insert one more records 103 item disk dell black successfully inserted and there are record also displaying the daily grid view okay now i'm gonna add one more button to to charge the records and rather it will be displayed in the daily git view in that case uh in this button click on i'll write code to charge for a result bar st equal to from s in db dot product in underscore tab fire product id equal to integer dot first type groups one dot text select s that i give you under that is equal to st okay let's debug yes now it's displaying all the records now 133 charts yes it's displaying only 103 product id 102 only 102 product id and if you put 101 then it will display only 101 product id okay [Music] now add one more button to delete the records from the sql database table using link you test is delete double click the button click event this button click event i will write code to delete records from the accessory database table so rst equal to from s in db dot product info underscore tab higher s dot product id equal to integer integer.first textbox1.x noted that you must use double equal in link you [Music] okay then select s dot fast [Music] okay db dot db dot delete and sir product info tabs dot delete and submit st break st okay now db dot submit change you must use the video submissions to execute the operation messagebox.com successfully deleted okay now debug now i'm gonna delete 101 records just click on delete successfully deleted but the result is not updates are instantly in the daily grid view uh to okay you can see it's successfully deleted to display the result instantly you must add you must call the method load data in the delete button click event okay now debug [Music] okay now i'm going to add a confirm message related to this confidential if you delete your records you cannot back this records again so i'm going to add a confirm message before completing the delayed operation okay so if master dodge are you sure to delete deleted records this is the message name and message box button dot yes no equal to dialog result dot yes noted that you must use double equal in if condition okay if yes then it will execute operation if no it will do nothing want you to delete are you sure to delete click on no it's not deleted and if you click on yes it will delete successfully deleted and the result also displays in the daily grid view [Music] you
Info
Channel: ProgrammingGeek
Views: 21,350
Rating: undefined out of 5
Keywords: programminggeek, crud in c# with sql using linq, crud in c# with sql linq, c# tutorial, linq to sql class, .dbml 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# linq, 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, virul
Id: zrzjuXV2qP0
Channel Id: undefined
Length: 21min 52sec (1312 seconds)
Published: Sat Oct 03 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.