Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / August 2005

Tip: Looking for answers? Try searching our database.

my first try - return from web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Support - 01 Aug 2005 14:19 GMT
I am leaning a lot and this is exciting stuff!
In infopath, I want to display a list box which values are populated by a
web service.
<WebMethod(Description:="This function provides you will all the news
release years we have")> Public Function NewsGetdates() As String

Question:
What type of data should I return from the web service? Should I return a
recordset ? What type of record set -
The data comes from a sqldatareader....
Dim stuff As SqlDataReader
stuff = cmd.ExecuteReader()
While stuff.Read
DatesSelectbox = DatesSelectbox & "<option value=" & stuff("year") & ">" &
stuff("year") & "</option>"
End While
NewsGetDates = DateSelectbox

This of course wont work because the list box does not understand <option
value, etc...

Thanks

Terry
Scott L. Heim [MSFT] - 01 Aug 2005 14:45 GMT
Hi Terry,

You will need to return a "dataset" for InfoPath to consume this data. Here
are some links that may be of benefit:

Lab 9: ADO.NET DataSets in InfoPath 2003
http://msdn.microsoft.com/office/understanding/infopath/training/default.asp
x?pull=/library/en-us/odc_ip2003_tr/html/odc_inf_lab_09.asp

826994: How to dynamically populate a drop-down list by calling a Web
service in InfoPath 2003
http://support.microsoft.com/default.aspx?scid=kb;EN-US;826994

Here is a VB.NET sample web method for returning the Company names from the
Customers table in the Northwind sample database:

   <WebMethod()> _
   Public Function ListCustomers() As DataSet
       Dim da As New SqlDataAdapter("SELECT CustomerID, CompanyName FROM
Customers", con)
       Dim dsCustomersOnly As New DataSet
       da.Fill(dsCustomersOnly, "Customers")
       Return dsCustomersOnly
   End Function

I hope this helps!

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
Support - 01 Aug 2005 15:42 GMT
thanks scott:
so this should work...?
<WebMethod(Description:="This function provides you will all the news
release years we have as a dataset")> Public Function NewsGetdatesDataset()
As DataSet
Dim MyInternals As New Internals
Return MyInternals.GetDatasetdates()
End Function

Public Function GetDatasetdates() As DataSet

   Dim cn As New SqlConnection(MyConnectionString)
   cn.Open()
   Dim cmd As New SqlCommand("Sproc_NEWSRELEASES", cn)
   cmd.CommandType = CommandType.StoredProcedure
   Dim adapt As New SqlDataAdapter(cmd)
   adapt.Fill(GetDatasetdates, "year")
   cn.Close()
   cn = Nothing
   cmd = Nothing
   MyConnectionString = Nothing
   Return GetDatasetdates()

End Function

> Hi Terry,
>
[quoted text clipped - 32 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Scott L. Heim [MSFT] - 02 Aug 2005 20:13 GMT
Hi Terry,

I have not specifically tested in the manner you describe but it seems as
though it should work.

Best Regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights
 
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.