Update underlying data using a DataSet and Webservices

A

Alex

Hello,
I am using a webservice to interact with my back end database. I have
successfully, created a few methods which pull data in a specific format. I
am having trouble using the update command in a DataAdapter and a newly
modified DataSet to update the database. I have seen a few articles which
demonstrate this, but when I try them the give me the errors, below is what I
have tried to do, and the error I get.


This exactly as it appeared in the article.

[WebMethod]
public DataSet GetCustomers()
{
SqlConnection con = new SqlConnection("server=servername;uid=login;
pwd=password;database=northwind");
SqlDataAdapter daCust = new SqlDataAdapter("Select * From
Customers", con);
DataSet ds = new DataSet();
daCust.Fill(ds, "Cust");
return ds;
}

[WebMethod]
public DataSet UpdateCustomers(DataSet ds)
{
SqlConnection con = new
SqlConnection("server=servername;uid=login;
pwd=password;database=northwind");
SqlDataAdapter daCust = new SqlDataAdapter("Select * From
Customers", con);
SqlCommandBuilder cbCust = new SqlCommandBuilder(daCust);
daCust.Update(ds, "Cust");
return ds;
}


The error I get is as follows;

System.InvalidOperationException: Update unable to find
TableMapping['tbl_DCustomers'] or DataTable 'tbl_DCustomers'.
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)

Does any one have any suggestions?
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top