Hello,
I seem to be missing a point here... but I really can't figure out what -
and I ve spend a full day on it and starting to feel realy stupid!
I have build a simple web service based on an example i found somewhre, that
simply retrieves data from an access database and returns it as a dataset.
It seems to work fine.
Then I built a simple client application for consuming this service. When I
use the Add New Data Source wizard, the service is succesfully added to the
project but I cannot see any of its properties on the Data Sources Window -
to be more precice nothing appears on the Data Sources Window.
When I did the VS documentation example for the google web service I could
see the tables and fields on the Data Sources window so I suspect I am
missing some extra step I must take.
here is the code for my web service's dateset return function:
public DataSet ListPhoneNumbers_Access()
{
OleDbConnection myConnection;
OleDbDataAdapter myDataAdapter;
DataSet myDataSet;
myConnection = new
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" +
Server.MapPath("/") + "\\PhoneNumbers\\PhoneNumbers.mdb");
myDataAdapter = new OleDbDataAdapter("SELECT * FROM PhoneNumbers",
myConnection);
myDataSet = new DataSet();
myDataAdapter.Fill(myDataSet, "PhoneNumbers");
return myDataSet;
}
If anyone has done this please help me !
Thanks,
eemanno
eemanno - 21 Dec 2005 08:57 GMT
Ok... I got it... it was much simpler than I thought, but I didn't have any
experience on that matters before.
The answer is to use typed datasets instead of the standard dataset object.
So here goes the solution for anyone else trying it:
First you create a new dataset (add new item - dataset) and add it to your
web service.
Then you drop the table from your database tha you want to use onto the
dataset designer so now you have your typed dataset.
Then you drop a dataset from the toolbox to your web service design view and
choose the typed dataset you have created, from the drop down list.
Finally, in your function that does the reading from the database, replace
the dataset object to your new object. Here is an example:
// PhoneNumbers is my typed dataset
public PhoneNumbers phoneNumbers1;
[WebMethod(Description = "The Phonenumbers Table")]
public PhoneNumbers GetPhoneNumbers()
{
OleDbConnection myConnection;
OleDbDataAdapter myDataAdapter;
PhoneNumbers myDataSet;
myConnection = new
OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source=" +
Server.MapPath("/") + "\\PhoneNumbers\\PhoneNumbers.mdb");
myDataAdapter = new OleDbDataAdapter("SELECT * FROM PhoneNumbers",
myConnection);
myDataSet = new PhoneNumbers();
phoneNumbers1 = new PhoneNumbers();
// you dont have to do both... you either return it from this function
or use the public object!
myDataAdapter.Fill(myDataSet, "PhoneNumbers");
myDataAdapter.Fill(phoneNumbers1, "PhoneNumbers");
return myDataSet;
}
> Hello,
>
[quoted text clipped - 39 lines]
> Thanks,
> eemanno