Help with web service

K

Kevin

I am experimenting with a web service - trying to connect to the
AdventureWorks sample database, But I can not get the web service to connect.

I have not got the correct syntax for the connection string for SqlConnection.

Any Ideas Appreciated....
 
S

Scott L. Heim [MSFT]

Hi Kevin,

Here is some sample VB.NET code that connects to the Northwind SQL Server
database to return a list of Customers:

** NOTE: You would need to replace "yourserver" in the connection string
with the appropriate name of your SQL Server machine.

<WebMethod()> _
Public Function GetCustomers() As DataSet
Dim CN As New SqlClient.SqlConnection("Data
Source=yourserver;Initial Catalog=Northwind;Integrated Security=SSPI")
CN.Open()

Dim strSQL As String = "SELECT CustomerID, CompanyName FROM
Customers"
Dim DA As New SqlClient.SqlDataAdapter(strSQL, CN)
Dim DS As New DataSet

DA.Fill(DS, "Customers")
Return DS
End Function

Let me know if this helps or if you need something else.

Best regards,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kevin

It was actually a problem with granting access to the ASPNET user... that
fixed the web service... now I have another problem...

When I try to connect to the web service method that returns a data set
(this works in the debug mode, I see all the XML data).. I get the following
error

[.......some stuff about GetEmplyeeRespone and GetEmployeeResult..........]

Undeclared XSD Element: '{http://www.w3.org/2001/XMLSchema}'schema

This is automatically generated by the web service???

Any ideas on how to solve this issue?

Regards
Kevin
 
S

Scott L. Heim [MSFT]

Hi Kevin,

Can you try using the sample code I sent against the Northwind (or Pubs)
database to see if you can reproduce the error? If you can, then please
post your web service code so we can have a look.

Thanks,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
K

Kevin

Hi Scott,

Thankyou for all of your help with this.... it seems to be a question that
no one is realy interested in answering.....

I have managed to make my web service work by using a work-around and
returning an XML document instead of a data set.... this is not ideal by any
means, as the changed data has to be manipulated in code when it is returned,
instead of the automatic functionality of the dataset...

It seems that InfoPath does not like the WSDL information generated by the
Web Service for the dataset, especially the "s:schema" reference from inside
the s:schema type....

It also did not like the data with its diffgram tags when I saved a copy of
the WSDL and edited it. (This allowed data access, but InfoPath could not use
the data).

I am using .NET 2.0 and ASP.NET 2.0 with Web Designer Express 2005 to create
the web service.

From my reading, I thought that the problems with InfoPath and ADO.NET
datasets had been resolved with SP1, but it looks like there might be some
new problems with .NET 2.0 or ASP.NET 2.0

Suggestions welcome, as I would like to use datasets idealy.

Kevin
 
S

Scott L. Heim [MSFT]

Ah - now I have not done any testing with ASP.NET 2.0 with InfoPath 2003
SP1. Do you have ASP.NET 1.1 available still? If so, do you get the same
result?

Also, do you have Access or SQL Server available? If so, I would like to
provide you with sample code that I have used with VS.NET to create a web
service that retrieves and updates data from these databases.

Thanks,

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