How To Get Data From Multiple Tables In C# Windows Form

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial i will show how to display data from two table in grid using link you to sqlite [Music] [Music] previous tutorial was crude operation using link use c-sharp link available in the description box below in this tutorial i will show how to display data from two table in grid using link you to sql in c sharp in that case first of all i just added a windows form with the name purchase info form just design it i just copy faced from the previous tutorial so in this form now change the back color of this form yes now this is looking nice change the control and remove the access button product item name is okay now design this one for purchase quantity text box three and this one for purchase price and this one for expiry date i will add a new for purchase info in this form so and button text is submit yes now go to the sql server explain the database database was pre-programming tutorial db and this uh this is the table name product info tab what i have shown you in previous tutorial now i'm gonna create a new tutorial with the name a new table with the name purchase info tab column is part i per id this purchase id this integer type american entity product id is a foreign key this is also integer foreign key references with the product in four tables product id column the product id column of product infotab is primary key okay now purchase quantity this is plot type and purchase price also plot plot uh allow you to use a decimal also and total as a purchase quantity into versus price okay multiplication of quantity and price total now purchase date versus date data type is date time okay execute yes commands completed successfully replace the table folder yes the purchase info tab also added in the server explorer and programming tutorial db so the heading yes purchase in 4k now go to the dbml file this is the programming class dbml i already added now just uh connect the uh database program to utility bin server explorer with the password yes now it's on the table folder and just drag the purchase info tab and drop it in the dbmo file link you file okay it's added you can see the product id uh is the references relation column okay now this is product textbox one two and the group three and purchase price in textbook oh this is combobox so change the control copy and faced yes this is tax box 4 for price and item figure 1 for date go to the button click event yes first of all at the reference of programming uh class data context this is the dbml file data context okay now right code to insert record insert purchase info uh in button click okay product id titles one dot text this is integer type so integer dot first equation dot text and then let's check the record yes so the column columns are purchased quantity versus quantity is double dot first textbox three times two per name so it's not uh need here okay now purchase price is purchase price from text box 4 double dot first i guess 4 because i declared is explode load convert with the double okay purchase date date time dot parse uh dating picker on the text okay now db dot purchase input tabs dot insert and submit sd db dot submit change finally it will display the message after successfully execution of this code message will be successfully submitted okay now i'm gonna add a method to load data instantly when i click on the button one submit button okay the method is load purchase write code htq from s in db dot purchase info product info tab and join it with the purchase input join o in db dot process in four tabs on s dot product id equal or dot product id okay now select new s dot product id s dot item name s dot design o dot purchase quantity ordered price and order total finally ordered passes date [Music] finally grid v1 [Music] dot data source equal to sd okay now i call this method in the button click event to load data after clicking the submit button and give you okay now change the form in program.cs my form name is a purchase info form so yes purchase info form start yes food product id or item name not showing so to display item name write code in that exchange event of textbooks one high for product id so this code to show item name based on product id so if the user dot text are not equal to blank then bar prot exist first of all it will check the product id exist or not so what uh exist equal to from sdb dot product info underscore tab here as dot product id equal to integer first exam.txt okay if prot exist dot count i mean if the result exist dot count greater than zero i mean if the record exists in the product product info tab then it will display the item name based on productivity service name equal to from smdb dot purchase product input have her s dot product id equal to integer dot first type responder text okay select s dot passed now take this to text equal to st name dot item name when you put product it will display the item name in the textbooks too if the product id not exist in the database table then it will display the text box to not found display the text not found in the textbooks too okay if product id not exist if taggersworld.txt equal to then textbox2 i mean item name textbox also blank see that one zero this is not found and one zero one laptop is found under two monitor one two three disk okay it's working perfectly now i'm gonna insert a record one zero one item laptop purchase quantity two first prices uh 550 000 they submit yes successfully submitted and the result also displaying the data grid view instantly okay one more record purchase quantity five and date also different yes the both result both record are displaying in the direct grid view but when i put 103 and inserting the record it will display the 102 and 103 also 101 and 103 also all the records so if you want to display the specific records so add higher clause add higher s dot product id code integer dot first text box one dot text now call this method in the text text box one text change event yes okay now debug see now it will display the record based on product id what you put in the product id text box you can see thanks for watching this tutorial [Music] you
Info
Channel: ProgrammingGeek
Views: 19,800
Rating: undefined out of 5
Keywords: how to get data from multiple tables in c#, how to get data from two tables using linq in c#, how to get data from multiple tables in c# linq, how to display data from multiple tables in c#, how to load data from multiple tables in c#, how to display data from multiple tables in c# linq, .dbml, get data from multiple sql
Id: Jr5gSsi-XeM
Channel Id: undefined
Length: 9min 28sec (568 seconds)
Published: Mon Apr 04 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.