I need a suggestion about DataGridView and DataTable

Socarsky

Well-known member
Joined
Mar 3, 2014
Messages
59
Programming Experience
Beginner
I need a suggestion that will give a proper idea. I have two tables in MS SQL 2008 Express. When my project open a WinForm that retrieve the data from DB as binding that to a DGW. So far so good but after an exact choosing to make an action that might insert data one of tables and the other action might insert data to the other table so I need to show both actions data in DGW together. Each time after an action to either of those tables I must show that in the DGW with the data which retrieved when WinForm calls and appears on screen.
What way might be good to handle this approach? Do I insert data either of the actions into SQL and show the data in DGW or store the data until the WinForm close then insert the data into SQL? I need opinions.
 
Are you querying the two tables separately and creating two separate result sets or are you executing one query and joining the two tables into a single result set?
I must use two query to retrieve result into DataTable, I must also add two columns to DGW they represent two different data as information from the other table.
 
I must use two query to retrieve result into DataTable, I must also add two columns to DGW they represent two different data as information from the other table.

Sorry, that doesn't really answer the question. Are you saying that you are executing two separate queries and populating two separate DataTables? Are you saying that you're executing two separate queries and their result sets have the same schema so you're populating a single DataTable with the results of both queries? Are you saying something else? If it's two queries into one DataTable, how do you know which table to save changes to?
 
Sorry, that doesn't really answer the question. Are you saying that you are executing two separate queries and populating two separate DataTables? Are you saying that you're executing two separate queries and their result sets have the same schema so you're populating a single DataTable with the results of both queries? Are you saying something else? If it's two queries into one DataTable, how do you know which table to save changes to?

Yes, I execute two separate queries. And keep their result set in two separated DataTables not only one, because there are two fields different than the other. But I just got an idea to get their result set like one single query, and that means one DataTable is enough. But let me think this idea and try first. So if I return your questions that I populate a DGW with two separated DataTables.
 
Back
Top Bottom