multiple tables in the dataset

tonywilliams

Member
Joined
Feb 12, 2007
Messages
9
Programming Experience
3-5
I am new to .net and am struggling along very slowly using datasets and adaptors etc. So first of all if anyone knows of any good tutorials it would be of great help.

But my problem at the moment is using a dataset which is filled with more than one table. My table adaptor uses a query which selects a single record from a table which has a relationship with a second table.

Everything works fine and I am getting all the data I need but its just referencing it that I am having trouble with. I can reference the additional table by accessing its column number, however I want to be able to access it through its name, like I can with the other table.

Here is my current code for the Fill

Me.Customer_detailsTableAdapter1.FillBycustref(Me.Comfortplus_customer_databaseDataSet_products.customer_details, txt_ref.Text)
Dim rowView As DataRowView = CType(Me.Customer_detailsBindingSource.Current, DataRowView)
Dim custRow As comfortplus_customer_databaseDataSet_products.customer_detailsRow = CType(rowView.Row, comfortplus_customer_databaseDataSet_products.customer_detailsRow)

The other table is "tbl_salesman" and I can get the value I need by referencing it as :

Me.Comfortplus_customer_databaseDataSet_products.customer_details.Rows(0).Item(25)

But how can i set it up so i can access it via the actual field name. ie tbl_salesman.salesman_name.

Many Thanks
 
im a bit lost, but:
1) tutorial? read the dw2 link in my signature. its the most excellent bit of online tutorial ever :)

2) normally when you have to refer to a datatable contents using numbers or string indexers its because you declared it as a generic datatable, not a strongly typed one:

VB.NET:
Dim myDT as [B]StronglyTypedDataTable[/B] = New StronglyTypedDataTable
myDT(0).PersonName = "Fred" [I]'set first row personname to fred[/I]
 
Dim myDT as [B]DataTable[/B] = New StronglyTypedDataTable [I]' STDT inherits from DT, so this is allowed BUT...[/I]
myDT.Rows(0).Item("PersonName") = "Fred" [I]'we now have to use only methods and properties exported by a generic datatable[/I]
[I]
[/I]

Hope this helps point you to a resolution. Either youre creating your table as weaktyped, or youre using the return value that has boxed it in a weak type.

If the OO terms of typing and boxing are unfamiliar to you then have a google for them
 
Back
Top