my first try - return from web service

S

Support

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
 
S

Scott L. Heim [MSFT]

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.
 
S

Support

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
 
S

Scott L. Heim [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top