Can I populate a Dataset from string values?

P

Paul D. Fox

I would like to read from Active Directory and populate a dataset to be
passed in a Web Service. I can get the data from AD just fine, but can I
populate a dataset with these values and do a "Return dataSetName" in my web
service?
 
C

Curt_C [MVP]

Paul said:
I would like to read from Active Directory and populate a dataset to be
passed in a Web Service. I can get the data from AD just fine, but can I
populate a dataset with these values and do a "Return dataSetName" in my web
service?

depending on how you are holing the values...
Just keep doing a .Add to the DS after you've created a blank one.
 
G

Guest

Dim dsUser As DataSet = New DataSet
Dim deSearch As DirectorySearcher = New DirectorySearcher

'set the search filter
deSearch.SearchRoot = de


deSearch.Filter = "(&(objectclass=group))"

'find the first instance
Dim results As SearchResultCollection = deSearch.FindAll()


'Create a new table object within the dataset
Dim tbUser As DataTable = dsUser.Tables.Add("Users")
tbUser.Columns.Add("UserName")
tbUser.Columns.Add("DisplayName")
tbUser.Columns.Add("EMailAddress")

Dim Result As SearchResult
For Each Result In results

'Create default row
Dim rwDefaultUser As DataRow = tbUser.NewRow()
rwDefaultUser("UserName") = Result.Properties("distinguishedname")
rwDefaultUser("DisplayName") = Result.Properties("displayname")
rwDefaultUser("EMailAddress") = Result.Properties("email")
tbUser.Rows.Add(rwDefaultUser)

Next

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
 
P

Paul D. Fox

Perfect! Thanks for your Help!

Paul

vinay said:
Dim dsUser As DataSet = New DataSet
Dim deSearch As DirectorySearcher = New DirectorySearcher

'set the search filter
deSearch.SearchRoot = de


deSearch.Filter = "(&(objectclass=group))"

'find the first instance
Dim results As SearchResultCollection = deSearch.FindAll()


'Create a new table object within the dataset
Dim tbUser As DataTable = dsUser.Tables.Add("Users")
tbUser.Columns.Add("UserName")
tbUser.Columns.Add("DisplayName")
tbUser.Columns.Add("EMailAddress")

Dim Result As SearchResult
For Each Result In results

'Create default row
Dim rwDefaultUser As DataRow = tbUser.NewRow()
rwDefaultUser("UserName") =
Result.Properties("distinguishedname")
rwDefaultUser("DisplayName") = Result.Properties("displayname")
rwDefaultUser("EMailAddress") = Result.Properties("email")
tbUser.Rows.Add(rwDefaultUser)

Next

--
http://pathidotnet.blogspot.com
=====
vInAypAtHi
o__
---_,>/'_------
(_) \(_)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top