How to add some columns from table and show them in another

Viewed 45

I am trying to create storage program.

I have 3 DataGridViews(Picture of menu), 1 is for Items, 2 is for Delivery notes and 3 is for showing Items which Delivery note contains(DbModel).

I want to add like 5 items from ItemsInStock to DeliveryNote and when I click on that DeliveryNote show the items that I add in DataGridView.

Then in the next DeliveryNote add 7 items and show them when I click on DeliveryNote and like that...

I was trying to do that with this code but it didn't work and I'm not sure if I'm on right way. I´m using Entity framework too.

string sqlString = "SELECT * FROM [ItemsInStock] " + "INNER JOIN [DeliveryNote] on [DeliveryNote].[Id] = [ItemsInStock].[DeliveryNoteId]";

ShowItemsInDeliveryNoteDgw.DataSource = sqlString.ToList();

Thanks

2 Answers

Change your SQL Query to

SELECT [DeliveryNote].* FROM [ItemsInStock] + INNER JOIN [DeliveryNote] on [DeliveryNote].[Id] = [ItemsInStock].[DeliveryNoteId]

To display DeliveryNote which shoud contains or refer to some items which are created in ItemsInStock table use this query:

SELECT DeliveryNote.* FROM [DeliveryNote] INNER JOIN [ItemsInStock] on 
[DeliveryNote].[Id] = [ItemsInStock].[DeliveryNoteId]
Related