I also noticed your 'more than one result' comment just now...see the
properties of the DataSet, DataTable, DataRow, etc. I alluded to in my
code. Once you understand these objects and how they tie together and
represent data, then you'll be on your way to a better understanding of
how to do this and actual databinding with DataSets in more complex
cases down the road....
A DataSet is made up of 0 or many DataTables, which is made up of 0 or
many DataRows. So think of a DataSet as a snapshot of a portion of a
database (a collection of tables), the DataTable is one of those tables,
and a DataRow is a row in one of the tables.
Notice in my code I drilled down using numbered indexes, since it seemed
you only had one value (a DataSet with one table with one row with one
value); for most of these indexes you should find values by using names
(e.g. if I have a column "foo" on a table called "table1", use the names
to access values, not how the data is ordered structurally).
Example:
Label1.Text = myDataSet.Tables["table1"].Rows[0]["foo"];
Craig Deelsnyder wrote:
ne***********@gmail.com wrote: Thank you. I used GetXML() and it returned what I wanted, but I am not
sure that was the right way to do it. What if it had had more than one
result?
Actually, you should just bind the Text to a certain value in the
DataSet. Since that's the type you're working with. GetXML is actually
creating XML on the fly and is not an efficient way of getting values
out of the DataSet (the DataSet is not stored as XML in memory).
In other words, do something like
DataSet myDataSet = (DataSet)GetCount.HelloWorld();
Label1.Text = myDataSet.Tables[0].Rows[0][0];
Assuming this is the first column, of the first row, of the first table
in the dataset (the only value in the DataSet). BTW, if this is the
only value being returned in this WebMethod, I'd recommend not using a
DataSet. It has alot of overhead; use a primitive type like int for the
return type of HelloWorld instead.
--
craig
Microsoft MVP - ASP/ASP.NET