Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select from two tables in a dataset
Message
 
To
01/05/2002 10:51:41
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00651324
Message ID:
00651373
Views:
15
You cannot run a Select SQL on existing tables in a DataSet. However, you can create a new table (similar to VFP cursor) with custom fields. You would have to iterate through rows in the existing table(s) and fill up your new table. Here is an example:
        'Assuming that we have a DataSet ds that contains a table

        'Create a new table (similar to VFP cursor)
        Dim oTable As New DataTable("MyTable")
        oTable.Columns.Add(New DataColumn("field1", GetType(String)))
        oTable.Columns.Add(New DataColumn("field2", GetType(Integer)))

        'Iterate through each row in an existing table
        'and add a new row in the newly created table
        Dim r As DataRow
        For Each r In ds.Tables(0).Rows
            Dim oNewRow As DataRow = oTable.DefaultView.AddNew().Row
            oNewRow("field1") = r("cname")
            oNewRow("field2") = r("iid")
        Next

        'Add the newly created table to the DataSet
        ds.Tables.Add(oTable)
Hope this helps.
Kamal


>Hello everyone. Can you run a SQL select command using the two datatables in a dataset to create a third table in the dataset? If so, how is this accomplished? Thanks for the help.
Previous
Reply
Map
View

Click here to load this message in the networking platform