update a dataset

  • Thread starter Thread starter Dino Chiesa [MSFT]
  • Start date Start date
D

Dino Chiesa [MSFT]

What is dsCity on the service side?

If I understand correctly, the winforms app is invoking a remote webmethod,
passing in the dataset. On the client (winforms) side, this dataset is
called dsCity. On the service side, it is called ds. The webservice has
*another* dataset, this one is also called dsCity. (But of course it is a
different dataset than the client-side dsCity!). What is the service-side
dsCity? how is it initialized? What is its scope?

To see what I mean, can you modify your code to include a

if (dsCity != null)

just before the merge statement in the webmethod code?

I predict you will no longer see the null ptr exception.
This of course does not fix your app, but it illustrates the problem.



-D
 
hi
i am trying to add a new row a dataset.. from my win app and then update it
to the db
thru my web service.


private void cmdSubmit_Click(object sender, System.EventArgs e)
{
DataRow dr = dsCity.Tables["city"].NewRow();
dr["cityid"]=3;
dr["cityname"]="newyork";
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);
}


[Web Method]
public void updateCity(DataSet ds)
{
SqlCommandBuilder cmdBuilder = new SqlCommandBuilder (daCity);
dsCity.Merge(ds); //error
}

however i get an error saying

System.NullReferenceException: Object reference not set to an instance of an
object.

why is that?
thanx
 
Back
Top