patelheenah
New member
- Joined
- Mar 24, 2008
- Messages
- 4
- Programming Experience
- Beginner
hi,
Can anyone help me out. Its very urgent to solve the following problem
i am using tab control to display the master-detail table.
I am using sql server 2000 as a back end
In my database i am having master i.e Purchase and detail i.e Purchase_Detail
The field of master are:
1) Voucher_No Pk
2) Date
.
.
.
.
Vendo_Name
Sub_total
Expense
Other Expense
Total Amount
In Detail table i am having
1) Voucher_No FK
2) Product Descritption
3) Quantity
4) Rate
5) Amount
I am having the tab control with two tab pages tabpage1 and tabpage2.
In tabpage1 i am to have show master table textboxes and in tabpage 2 i have datagridview. Can you please go through the code:
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As New SqlConnection(str)
Dim ds As New DataSet
Dim dt1 As New DataTable
Dim dt2 As New DataTable
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)
Dim da1 As SqlDataAdapter
da1 = New SqlDataAdapter("Select * from Purchase", con)
Dim da2 As SqlDataAdapter
da2 = New SqlDataAdapter("Select* from purchase_Detail", con)
da1.FillSchema(dt1, SchemaType.Mapped)
da2.FillSchema(dt2, SchemaType.Mapped)
da1.Fill(dt1)
da2.Fill(dt2)
Dim rel As DataRelation
rel = New DataRelation("FK__Purchase___Vouch__276EDEB3", ds.Tables(0).Columns("Voucher_No"), ds.Tables(1).Columns("Voucher_No"))
ds.Relations.Add(rel)
Dim PBindingSource As BindingSource
PBindingSource = New BindingSource(Me.components)
Me.PBindingSource.DataMember = ds.Tables(0).TableName
Me.PBindingSource.DataSource = ds
Me.TextBox1.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Voucher_No", True))
Me.TextBox2.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Bill_No", True))
Me.DateTimePicker1.DataBindings.Add(New Binding("Value", Me.PBindingSource, "Bill_Date", True))
Me.TextBox4.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Challan_No", True))
Me.DateTimePicker2.DataBindings.Add(New Binding("Value", Me.PBindingSource, "Challan_Date", True))
Me.TextBox6.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Sub_Total", True))
Me.TextBox7.DataBindings.Add(New Binding("Text", Me.PBindingSource, "VAT_Charges", True))
Me.TextBox8.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Vat_percent", True))
Me.TextBox9.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Other_Charges", True))
Me.TextBox3.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Total_Amount", True))
Dim bspurchasedetail As New BindingSource
'bspurchasedetail = New BindingSource(Me.components)
Dim datagridview1 As New DataGridView
Me.bspurchasedetail.DataSource = PBindingSource
'Me.bspurchasedetail.DataMember = "FK__Purchase___Vouch__276EDEB3"
Me.DataGridView2.DataSource = ds.Tables("Purchase_Detail")
Me.DataGridView3.DataMember = "FK__Purchase___Vouch__1367E606"
end sub
end class
When i compile the then its not working . To display all the data of master in respective textbox and all the information of particular voucherno in datagridview
Secondly, if i want this to be in edit mode then how its possible.
A Quick response will be awaited please help me out.
Can anyone help me out. Its very urgent to solve the following problem
i am using tab control to display the master-detail table.
I am using sql server 2000 as a back end
In my database i am having master i.e Purchase and detail i.e Purchase_Detail
The field of master are:
1) Voucher_No Pk
2) Date
.
.
.
.
Vendo_Name
Sub_total
Expense
Other Expense
Total Amount
In Detail table i am having
1) Voucher_No FK
2) Product Descritption
3) Quantity
4) Rate
5) Amount
I am having the tab control with two tab pages tabpage1 and tabpage2.
In tabpage1 i am to have show master table textboxes and in tabpage 2 i have datagridview. Can you please go through the code:
Private Sub Form6_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim con As New SqlConnection(str)
Dim ds As New DataSet
Dim dt1 As New DataTable
Dim dt2 As New DataTable
ds.Tables.Add(dt1)
ds.Tables.Add(dt2)
Dim da1 As SqlDataAdapter
da1 = New SqlDataAdapter("Select * from Purchase", con)
Dim da2 As SqlDataAdapter
da2 = New SqlDataAdapter("Select* from purchase_Detail", con)
da1.FillSchema(dt1, SchemaType.Mapped)
da2.FillSchema(dt2, SchemaType.Mapped)
da1.Fill(dt1)
da2.Fill(dt2)
Dim rel As DataRelation
rel = New DataRelation("FK__Purchase___Vouch__276EDEB3", ds.Tables(0).Columns("Voucher_No"), ds.Tables(1).Columns("Voucher_No"))
ds.Relations.Add(rel)
Dim PBindingSource As BindingSource
PBindingSource = New BindingSource(Me.components)
Me.PBindingSource.DataMember = ds.Tables(0).TableName
Me.PBindingSource.DataSource = ds
Me.TextBox1.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Voucher_No", True))
Me.TextBox2.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Bill_No", True))
Me.DateTimePicker1.DataBindings.Add(New Binding("Value", Me.PBindingSource, "Bill_Date", True))
Me.TextBox4.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Challan_No", True))
Me.DateTimePicker2.DataBindings.Add(New Binding("Value", Me.PBindingSource, "Challan_Date", True))
Me.TextBox6.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Sub_Total", True))
Me.TextBox7.DataBindings.Add(New Binding("Text", Me.PBindingSource, "VAT_Charges", True))
Me.TextBox8.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Vat_percent", True))
Me.TextBox9.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Other_Charges", True))
Me.TextBox3.DataBindings.Add(New Binding("Text", Me.PBindingSource, "Total_Amount", True))
Dim bspurchasedetail As New BindingSource
'bspurchasedetail = New BindingSource(Me.components)
Dim datagridview1 As New DataGridView
Me.bspurchasedetail.DataSource = PBindingSource
'Me.bspurchasedetail.DataMember = "FK__Purchase___Vouch__276EDEB3"
Me.DataGridView2.DataSource = ds.Tables("Purchase_Detail")
Me.DataGridView3.DataMember = "FK__Purchase___Vouch__1367E606"
end sub
end class
When i compile the then its not working . To display all the data of master in respective textbox and all the information of particular voucherno in datagridview
Secondly, if i want this to be in edit mode then how its possible.
A Quick response will be awaited please help me out.