Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do add a single entry for two tables using linq to entities
    primarykey
    data
    text
    <p><img src="https://i.stack.imgur.com/ZE6ua.png" alt="enter image description here">I have table called</p> <pre><code> product product_id product_Name product_Price product_Description product_image category_id another table category category_id category_name </code></pre> <p>i have a new form with textboxes like</p> <pre><code> txtprodname txtproddescrip txtproductprice picturebox1 txtcategoryname </code></pre> <p>i am trying to add the new product to producttable by using following code</p> <p>i am using entity framework..</p> <pre><code> public byte[] imageToByteArray(System.Drawing.Image image) { MemoryStream ms = new MemoryStream(); image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); return ms.ToArray(); } private void btnSave_Click(object sender, EventArgs e) { Image image = pictureBox1.Image; byte[] bit = null; bit = imageToByteArray(image); product pd = new product(); pd.product_Name = txtprodname.Text; decimal price = Convert.ToDecimal(txtproductprice.Text); pd.product_Price = price; pd.product_Description = txtproddescrip.Text; pd.product_Image = bit; tsgentity.AddToproducts(pd); tsgentity.SaveChanges(); this.Close(); } </code></pre> <p>I am trying to add new product to the product table .. but i dont have any idea how to add the category name to category table .......by using linq</p> <p>how do i add category name to category table and update the product table with category name that i have entered...</p> <p>how do update the category id in product table with this name entered along with the new product added to the product table</p> <p>can any one help on this ....</p> <p>i am using winforms .....and c# language</p> <p>this is my entity diagram....</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload