473,322 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

VB.NET: TabControl DataRelations

I've got 3 tables. Table1 is the master table and tables 2 & 3 are detail tables related to table1. On the VB.net Windows form I've added several textboxes binded to table1 as a header and a tabcontrol containing seperated pages for each detail table. Each containing a datagrid and navigator. I've managed to setup a relation between table1 and table2 and all the controls works fine but for the life of me I can't get the relation between table1 and table3 to work. Neither the navigator nor the grid is working properly. Please help. Below is the code I use:

Expand|Select|Wrap|Line Numbers
  1.  Dim daMatchSetup As Odbc.OdbcDataAdapter 
  2. Dim daTable2 As Odbc.OdbcDataAdapter
  3. Dim daTable3 As Odbc.OdbcDataAdapter
  4.  
  5. Dim parentCol2() As DataColumn
  6. Dim childCol2() As DataColumn
  7.  
  8. Dim parentCol3() As DataColumn
  9. Dim childCol3() As DataColumn
  10.  
  11. Dim rel2 As DataRelation
  12. Dim rel3 As DataRelation
  13.  
  14.  
  15. Try
  16. MyConn.Open()
  17. MyDataSet = New DataSet
  18.  
  19. daTable1 = New Odbc.OdbcDataAdapter
  20.  
  21. MyDataSet = GetDataSet(MyDataSet, MyConn, daTable1, _
  22. "SELECT * FROM table1", "table1")
  23.  
  24. daTable2 = New Odbc.OdbcDataAdapter
  25. MyDataSet = GetDataSet(MyDataSet, MyConn, daTable2, _
  26. "SELECT * FROM table2", "Table2")
  27.  
  28. daTable3 = New Odbc.OdbcDataAdapter
  29. MyDataSet = GetDataSet(MyDataSet, MyConn, daTable3, _
  30. "SELECT * FROM table3", "Table3")
  31. Catch
  32.  
  33. End Try
  34. MyConn.Close()
  35.  
  36. parentCol2 = New DataColumn() {MyDataSet.Tables("table1").Columns("Table1_Field1"), MyDataSet.Tables("Table1").Columns("Table1_field2")}
  37. childCol2 = New DataColumn() {MyDataSet.Tables("Table2").Columns("Table1_field1"), MyDataSet.Tables("Table2").Columns("Table1_field2")}
  38.  
  39. rel2 = New DataRelation("Table1_Table2", parentCol2, childCol2)
  40. rel2.Nested = True
  41. MyDataSet.Relations.Add(rel2)
  42.  
  43. parentCol3 = New DataColumn() {MyDataSet.Tables("Table1").Columns("Table1_field1"), MyDataSet.Tables("Table1").Columns("Table1_field2")}
  44. childCol3 = New DataColumn() {MyDataSet.Tables("Table3").Columns("Table1_field1"), MyDataSet.Tables("Table3").Columns("Table1_field2")}
  45.  
  46. rel3 = New DataRelation("Table1_Table3", parentCol3, childCol3)
  47. rel3.Nested = True
  48. MyDataSet.Relations.Add(rel3)
  49.  
  50. frmTest.bnsTable1.DataSource = MyDataSet
  51. frmTest.bnsTable1.DataMember = "table1"
  52.  
  53. frmTest.bnsTable2.DataSource = frmTest.bnsTable1
  54. frmTest.bnsTable2.DataMember = "Table1_Table2"
  55.  
  56. frmTest.bnsTable3.DataSource = frmTest.bnsTable1
  57. frmTest.bnsTable3.DataMember = "Table1_Table3"
  58.  
  59. frmTest.bnvTable1.BindingSource = frmTest.bnsTable1 
  60. frmTest.bnvTable2.BindingSource = frmTest.bnsTable2
  61. frmTest.bnvTable3.BindingSource = frmTest.bnsTable3
  62.  
  63. frmTest.dgvTable2.DataSource = frmTest.bnsTable1
  64. frmTest.dgvTable2.DataMember = "Table1_Table2"
  65.  
  66. frmTest.dgvTable3.DataSource = frmTest.bnsTable1
  67. frmTest.dgvTable3.DataMember = "Table1_Table3"
  68.  
Thanks in advance.
Aug 24 '06 #1
0 1293

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Kevin | last post by:
Hi All I have a couple of questions, I am not at a machine with VS.NETso that is why I am asking them here 1. When working with a dataset, how do I go to a specific record and update a field...
4
by: hennovanrensburg | last post by:
Hi all, I've noted a couple of posts regarding the speed of a datagrid in a ..net win app. My datagrid consists of 37 rows and 12 cols, and is unacceptably slow. How can this be? Should I...
0
by: George Durzi | last post by:
I have a DataSet with 3 tables, and two DataRelations dsSubs.Tables.TableName = "Subscriptions" dsSubs.Tables.TableName = "AccountManagers" dsSubs.Relations.Add "AccountManagers_Subscriptions",...
2
by: Patrick McGuire | last post by:
I want to place a tabControl with almost identical properties on several forms. I think the best way is to define a UserControl that inherits System.Windows.Forms.TabControl, and place all my...
9
by: Michael Turner | last post by:
Hi Guys Having problem with the tab control, I need to set the background color to something different than the standard, I have found code on the web and now can redraw the tabpage buttons so...
2
by: Dave | last post by:
We've created a robust client server application over the past 3 years on the .NET framework version 1.1 using c#. We layed all of our marbles in creating strongly typed datasets and for the most...
3
by: Dave | last post by:
We've created a robust client server application over the past 3 years on the .NET framework version 1.1 using c#. We layed all of our marbles in creating strongly typed datasets and for the most...
2
by: naamala | last post by:
Hi, I need to change individual tab's background color in TabControl in windows form. I am able to change the Backgrond color of each tab in TabControl with changing the property...
1
by: =?Utf-8?B?QWxleCBLLg==?= | last post by:
Hi all In a Visual Studio 2005 C# project, I have a simplest tabcontrol with two tabpages. When I set tab control's Alignment property to Right, tab texts (captions) disappear. Does anybody...
4
by: Steve | last post by:
Hi All Is there any way to change the colour of the Tabcontrol Tab header strip I have found how to override the individual Tab header colours in the drawitem event but the rest of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.