dc1 = dataset1.Tables("Suppliers").Columns("SupplierID")
下面是mshelp
' Create the ConnectionString and create a SqlConnection.
' Change the data source value to the name of your computer.
Dim cString As string = "user id=sa;" &
_
"password=;" &
_
"initial catalog=northwind;" &
_
"data source=MyComputerName/NetSDK;" &
_
"Connect Timeout=5"
Dim cnNorthwind As SqlConnection = new SqlConnection(cString)
' Create a SqlDataAdapter for the Suppliers table.
Dim adpSuppliers As SqlDataAdapter = new SqlDataAdapter()
' A table mapping tells the adapter what to call the table.
adpSuppliers.TableMappings.Add("Table", "Suppliers")
cnNorthwind.Open()
Dim cmdSuppliers As SqlCommand = _
new SqlCommand("SELECT * FROM Suppliers", cnNorthwind)
cmdSuppliers.CommandType = CommandType.Text
adpSuppliers.SelectCommand = cmdSuppliers
Console.WriteLine("The connection is open.")
ds = New DataSet("Customers")
adpSuppliers.Fill(ds)
' Create a second SqlDataAdapter and SqlCommand to get
' the Products table, a child table of Suppliers.
Dim adpProducts As SqlDataAdapter = new SqlDataAdapter()
adpProducts.TableMappings.Add("Table", "Products")
Dim cmdProducts As SqlCommand = _
new SqlCommand("SELECT * FROM Products", cnNorthwind)
adpProducts.SelectCommand = cmdProducts
adpProducts.Fill(ds)
cnNorthwind.Close()
Console.WriteLine("The connection is closed.")
' You must create a DataRelation to link the two tables.
Dim dr As DataRelation
Dim dc1 As DataColumn
Dim dc2 As DataColumn
' Get the parent and child columns of the two tables.
dc1 = ds.Tables("Suppliers").Columns("SupplierID")
dc2 = ds.Tables("Products").Columns("SupplierID")
dr = new System.Data.DataRelation("suppliers2products", dc1, dc2)
ds.Relations.Add(dr)