hi
well actually is like this..
web service
[WebMethod]
public DataSet getAllCities()
{
SqlDataAdapter daCity ;
DataSet dsCity;
string sqlQuery = "select * from City";
daCity=new SqlDataAdapter(sqlQuery,conn);
dsCity= new DataSet();
daCity.Fill(dsCity,"City");
return dsCity;
}
[WebMethod]
public void updateCity(DataSet ds)
{
string sqlQuery = "select * from City";
SqlDataAdapter daCity=new SqlDataAdapter(sqlQuery,conn);
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder (daCity);
DataSet dsCity= new DataSet();
daCity.Fill(dsCity,"City");
dsCity.Merge(ds);
dsCity.Tables["City"].AcceptChanges();
daCity.Update(dsCity); //i get an error here.
}
-------------------------------
Win application the client
private DataSet dsCity; //global
private void Form1_Load(object sender, System.EventArgs e)
{
//fill the city combo
ser=new Service1();
dsCity=ser.getAllCities();
cmbPickCity.Items.Clear();
foreach (DataRow dr in dsCity.Tables["City"].Rows)
{
if(!dr.IsNull(0))
cmbPickCity.Items.Add(dr["CityName"]);
}
cmbPickCity.SelectedIndex=0;
}
private void cmdSubmit_Click(object sender, System.EventArgs e)
{
DataRow dr = dsCity.Tables["city"].NewRow();
dr["cityid"]=3;
dr["cityname"]="AS";
MessageBox.Show(dsCity.Tables["city"].Rows.Count.ToString());
dsCity.Tables["city"].Rows.Add(dr);
MessageBox.Show(dsCity.Tables["city"].Rows.Count.ToString() + " state=" +
dsCity.Tables["City"].Rows[2].RowState.ToString());
ser=new Service1();
ser.updateCity(dsCity);
}
---------
and it gives me this error
System.InvalidOperationException: Update unable to find
TableMapping['Table'] or DataTable 'Table'.
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
why doesnt it update the database.
thanx for your help