Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2005

Tip: Looking for answers? Try searching our database.

Web Services and Data Sources Window on VS2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
eemanno - 19 Dec 2005 22:21 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.