Here's an example:
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?
thanks...> 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
Jeppe,
That did help.
Thank you very much.
Eych
> That did help.
> Thank you very much.
No propblemo. :-)
Jeppe
Saturday, March 31, 2012
sub-selecting a DataTable?
Labels:
asp,
callwebservice,
datasetdsmydata,
datatable,
dim,
dsmydata,
dtuserstable,
exampledim,
net,
param1,
param2,
sub-selecting,
tables,
users
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment