I have two Dataset naming Employee and Salary

Employee Dataset have three colomns coloumns ------------- Emp_id, Name, Address,

Salary Dataset have three more coloumns -------------------- Sal_id, Salary, Emp_id

in Employee Dataset Emp_id is parimary Key

in Salary Dataset Emp_id is Foreign Key

Now I want that both the dataset in Windows Form Employee Dataset in Details

and Salary Dataset in DatagridView.

that all things I done

Now what I required is when I select a Emp_id is 1

then in Datagridview they also show a detail of Emp_id is 1

I thing I clear my point.

and when you have any difficulty understanding this

please asked me

Please help me out in this



Re: Windows Forms General Windows Form Problem

vinoth kumar.R


This is possible u said u maintain 2 dataset then fill the second dataset query with parameter

pass the pass the parameter for the second dataset in the second dataset write the following query

Select Sal_id, Salary from salarytbl where empid = '" + empcode"'

pass the parameter value for empcode.

Re: Windows Forms General Windows Form Problem


but I want that empcode automatically show as per employee table

means which id shown in Employee table automatically salary table take this value

reply please

Re: Windows Forms General Windows Form Problem

vinoth kumar.R

no prob also select empid from the table

Re: Windows Forms General Windows Form Problem

Gavin Jin - MSFT

Hi, first I will check my understanding with you, if there is any misunderstanding, please feel free to let me know.

You want to show related data from another dataset synchronically, isn’t it

I think you can use BindingSource to create a master-detail relation with these two datatables.

Here is a sample ,hope it helps

Imports System.Data


Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles MyBase.Load

Dim conn As New SqlConnection("Server=(Local);" & _

"DataBase=Northwind; Integrated Security=SSPI")

Dim sqlstr As String = "SELECT * FROM Employees"

Dim ds As New DataSet

Dim dt1 As New DataTable

Dim dt2 As New DataTable



Dim da1 As New SqlClient.SqlDataAdapter _

("Select * from Orders", conn)

Dim da2 As New SqlClient.SqlDataAdapter _

("Select * from [Order Details]", conn)

da1.FillSchema(dt1, SchemaType.Mapped)

da2.FillSchema(dt2, SchemaType.Mapped)

Dim rel As New DataRelation("FKOrders_Detail_Orders", _

ds.Tables(0).Columns("OrderID"), _



Dim bsOrders As New BindingSource

bsOrders.DataMember = ds.Tables(0).TableName

bsOrders.DataSource = ds

DataGridView1.DataSource = bsOrders

Dim bsOrderDetails As New BindingSource

bsOrderDetails.DataSource = bsOrders

bsOrderDetails.DataMember = "FKOrders_Detail_Orders"

DataGridView2.DataSource = bsOrderDetails



End Sub

End Class


Re: Windows Forms General Windows Form Problem



I am working in C# not in Visual Basic

can you explain it in C#

Re: Windows Forms General Windows Form Problem

Gavin Jin - MSFT

Hi, you can follow this article .There is a C# code example creates a master/detail form using two DataGridView controls bound to two BindingSource components. Hope it helps.

Best Regards