Webservices and strongly typed datasets


T

Thomas Zaleski

Dear group,

I have a webservice which I use as a datalayer. Basically its function
is to fill a strongly typed dataset with data and return it to my
webapplication that called it.

My webservice has the following method:

<WebMethod()> Public Function FillCatalog(ByVal ds As catalogds) As
catalogds
Dim myConnection As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim myDataAdapter As SqlDataAdapter = New
SqlDataAdapter("procCatalogGetList", myConnection)

myDataAdapter.SelectCommand.CommandType =
CommandType.StoredProcedure

myConnection.Open()

myDataAdapter.TableMappings.Add("Table", "products")
myDataAdapter.TableMappings.Add("Table1", "productprice")
'sda.TableMappings.Add("Table2", "productspecial")

myDataAdapter.Fill(ds)
myConnection.Close()

Return ds
End Function


Now if I create a aspx file in that project to call this using the below
code:

Dim catalogds As catalogds

Dim dp As vna = New vna
catalogds = New catalogds
dp.FillCatalog(catalogds)

Dim pr As catalogds.productsRow =
catalogds.products.FindByproduct_id(productid)
Dim ppr As catalogds.productpriceRow() = pr.GetproductpriceRows


This code works fine locally. But if I try to run this code on my
webapplication that has consumed the webservice, it seems that the
dataset comes back empty. The code I use on my webapplication (assuming
the reference to the webservice is 'vna') is as follows:


Dim catalogds As vna.catalogds

Dim dp As vna.vna = New vna.vna
catalogds = New vna.catalogds
dp.FillCatalog(catalogds)

Dim pr As vna.catalogds.productsRow =
catalogds.products.FindByproduct_id(productid)

Dim ppr As vna.catalogds.productpriceRow() = pr.GetproductpriceRows

The error occurs in the last line of code. It is acting as if there is
no data in the dataset. Has anyone any similar experience with this?
Please let me know.

Thanks
 
Ad

Advertisements


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