Reputation: 445
I'm using a dataset and web service and in my web service method I call and execute the procedures that I have created in the database so my question is I have the result from the database but I didn't know to use or call the data itself.
how can I do that?
I tried searching but all the results that I reached were about the connection string that I don't want use. this is my first time using dataset and web service so maybe I was searching with wrong key words.
here is my code and the last line is where I stopped and didn't know how to continue.
newCityTable has the result of the procedure.
OrderDatasetTableAdapters.getCityNameTableAdapter newOrder = new OrderDatasetTableAdapters.getCityNameTableAdapter();
newOrder.GetCityNameData();
OrderDataset.getCityNameDataTable newCityTable;
newCityTable = newOrder.GetCityNameData();
Upvotes: 3
Views: 7323
Reputation: 822
You can also do the follow (without a conversion to an item array) which may be more efficient:
city = newCityTable.Rows[i].Columns[0].ToString();
or in general if you had a double for loop:
city = newCityTable.Rows[i].Columns[j].ToString();
Upvotes: 1
Reputation: 445
Finally I found the answer and here I will share it with everyone. maybe someone will find it helpful.
string city;
// i here refers to the variable in a for loop. you can do whatever you want before like using loop, fetch a specific row or create an array..etc but this is the way to get the data that you want
city = (string) newCityTable.Rows[i].ItemArray[0];
Upvotes: 1