Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i have two tables in database like
SQL
checkout_id  /   product_id   /   product_name  /   quantity  /  unit_price   /   user_name
    1                 54           gh                 3             123               oman
    2                 55           fgh                5             900            choudhary
    3                 56           try                6             809              x-men  

above is my check out table which have the complete information of last checkout
below is my book_detail table
SQL
book_id    /     quantity     /   book_name   /   price
   53              20                asley         800
   54              10               janmes         123
   55              16               horror         900
   56              25                divine        809
   57              30                trumph         555
   58              40                 dekh          788

now i want to find remaing quantity and wants to update in book_detail table

so how to solve this problem i am not getting proper solution bcz i m new on .net platform
as well as sql
i have tried this but its not enough or not good
C#
var checkoutbook = from st in obj.Checkout_tables
                             where st.User_name== Session["user"].ToString()
                             select st.Product_id;

             var bookqan  = from st in obj.Book_details
                            where checkoutbook.Contains(st.Book_Id)
                            select st.Quantity;
             var bookid = from st in obj.Book_details
                           where checkoutbook.Contains(st.Book_Id)
                           select st.Book_Id;
             Int32 z = checkoutbook.Count();
             for (int s = 0; s < z; s++)
             {
                 Int32 st1 = (from st in obj.Book_details
                           where st.Book_Id == checkoutbook[s]
                           select st.Quantity).SingleOrDefault();

             }
Posted
Updated 28-Oct-13 20:12pm
v9
Comments
Tom Marvolo Riddle 29-Oct-13 1:53am    
Please dont't ask us to write query for you.What have you tried?
Tom Marvolo Riddle 29-Oct-13 1:55am    
Then what is this:"u can write as well as if u can do it"
Tom Marvolo Riddle 29-Oct-13 1:59am    
We are not here to do your homework.Go home,try it and Don't Shout.
Thanks7872 29-Oct-13 1:57am    
Excuse me,how you assumed that? Whatever he stated is absolutely right. We are not here to do your home work. Have you tried writing query your self? If yes,where is it? Whats the problem with that?

And don't repost the question,it doesn't mean that you will get response.
Thanks7872 29-Oct-13 2:30am    
i have tried this but its not enough or not good.

How?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900