Search code examples
sql-servervb.netviewstrongly-typed-dataset

Bind multiple tables to a DataGridView in .net and sql server


I am working on a project to manage the inventory of a small business. I have a database with SQL server 2014 that contains several tables including: "Inventory", "Product", "Location", "Department", "Provider".

I am currently using the offline method ado.net. I can't use LINQ :(

I need to select certain fields from 5 tables listed above and bind them to a DataGridView.

For example, I want to take code, description, tax, price from Product; Quantity, company from Inventory; Description from Location; DepartmentCode from Department; providerCode from Provider; and bind all those fields to one DataGridView.

I'm currently using a "strongly typed dataset" that contains my entire database.

I did some research before asking a question here. Some people say to take all the information and deposit in a DataTable. Is it the good way? Is there a better way to do it? Maybe I can use stored procedure?

In addition, the information in the datagridview can be updated!

If you need more information, just ask it!


Solution

  • You should create an sql view from the command that join all these tables. And use it as a source of a tableadapter in the dataset designer.

    You can use stored procedure but it is not best practice because views provide more features like indexes.