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?
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?