why cant i display my 2 table records in two datagridviews in windows form?

Joined
Aug 8, 2011
Messages
20
Location
Batangas City, Philippines
Programming Experience
Beginner
why cant i display my 2 table records in two datagridviews in windows form?

it only display the records of table 1 to the 2 datagrid views

here is my code

Imports System.Data.SqlClient

Private cs As New SqlConnection("Data Source=JARM\SQLEXPRESS;Initial Catalog=ccs;Integrated Security=True")
Private da As New SqlDataAdapter("SELECT * FROM act1styearsem1", cs) -------------------------------------table1
Private da1 As New SqlDataAdapter("SELECT * FROM act1styearsem2", cs) --------------------------------------table2
Private ds As New DataSet


da.Fill(ds, "act1styearsem1")
Ivan1DataGridView.DataSource = ds.Tables("act1styearsem1")


da1.Fill(ds, "act1styearsem2")
IvanDataGridView.DataSource = ds.Tables("act1styearsem2")
 
My guess would be that it is working and you just have the same data in both tables. I can't see why that code, as presented, wouldn't work.

That said, do you really have two tables for the same data for two semesters? You should just have one table with a Semester column, or maybe another table with the year and semester in it and a foreign key to that table.
 
the two daragrids shows only the table 1 records.

the difference between the two table records is the semester and grades


is it ok that all my tables are in one dataset only?


i really dont know how to connect different tables into one, so i just sticked to this kind of step
 
the two daragrids shows only the table 1 records.
If you say so but, based on that code, I can't see how that's possible.
is it ok that all my tables are in one dataset only?
Yes, although there's no advantage to it if there's no DataRelation between them and you're not passing the DataSet around. I would just use two separate DataTables.
i really dont know how to connect different tables into one, so i just sticked to this kind of step
You do now because I told you. Add a Semester column and put all the data in one table. You might also add a Year column if it's a ppropriate. You can then execute a query with the Year and Semester in the WHERE clause to only get one semester's worth of data.
 
Back
Top