13,4 Pass một Dataset Quay lại từ một XML Web Service Tôi muốn để có thể nhận được nhiều dữ liệu hơn so với giá trị một chỉ duy nhất. Làm thế nào để lấy toàn bộ dữ liệu từ một dịch vụ Web? | Pass a Dataset Back from an XML Web Service I want to be able to get more data than just a single value. How do I retrieve a whole dataset from a Web Service Technique When you need to pass back a record or multiple records from a Web Service you have to pass it back as a DataSet object rather than a DataTable object. For this How-To you will pass back the record of the user who is requested. Before returning the record however the code removes the Password column. You don t particularly want that information going out over the Net see Listing . Listing Passing Back a DataSet Object WebMethod Public Function GetUserInfo ByVal strUserlD As String As DataSet Dim ocnn As New Provider Data Source E InetPub wwwroot SecurityWebService Dim odaUsers As New _ Select from tblUsers Where UserID strUserID . ocnn Dim dsUsers As New DataSet dsUsers -- remove the password column 0 . Password Return dsUsers End Function Note Although you could limit the SELECT string to only return the necessary columns and not have to delete the Password column there are two reasons for coding it the way it was done. 1. It shows how to delete columns from a data table. 2. If the goal is to include all the columns in the table and accept the Password column then when other columns are added you will not have to touch the code because the is being used. Tip When referring to tables on the receiving end as displayed in step 2 of this How-To you have to refer to tables in the dataset by their ordinal values. Therefore some information in the description of the Web Service method about the dataset might be warranted. Steps To preview this How-To open the solution called Visual Basic .NET-Chapter 13 found in this chapter s folder. On the main form click on the button labeled How-To . The form for How-To then opens. If you