> Dim dsMyData As DataSet
dsMyData = CallWebService(Param1,Param2)
Dim dtUsersTable As DataTable = dsMyData.Tables("Users")
I have a Web service that fills dsMyData with a couple tables.
My question is, from dsMyData.Tables("Users"), which contains all
users, how can I create another datatable that only returns for
UserID=1?
This may not be the easiest way, but it should work:
'line below copies structure of Users table to NewUsers table
Dim newUserTable As DataTable = dsMyData.tables("Users").Clone
'line below renames the cloned table as to avoid naming conflicts
newUsersTable.tableName = "NewUsers"
'selects users with userid=1 and imports into NewUsers table
For Each dr As DataRow In dsMyData.tables("Users").Select("UserID=1")
newUsersTable.ImportRow(dr)
Next
' adds the newUsers table to the dataset
dsMyData.Tables.Add(newUsesTable)
Hope it helps.
Jeppe Jespersen