dataset update prob

Discussion in 'ASP .Net' started by drishtik, Sep 9, 2003.

  1. drishtik

    drishtik Guest

    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
    drishtik, Sep 9, 2003
    #1
    1. Advertising

  2. drishtik

    Ian Guest

    Hi,

    On the error line you're calling a method on dsCity. Where is dsCity
    defined (and created)? And is the ds parameter definitely not null?

    Ian

    "drishtik" <> wrote in message
    news:...
    > 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
    >
    >
    >
    >
    Ian, Sep 12, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,791
    Chris Taylor
    Oct 31, 2003
  2. JimO

    DataSet and dataSet

    JimO, Mar 1, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    517
    Mary Chipman [MSFT]
    Mar 8, 2006
  3. Joseph D. DeJohn

    DataSet to DataSet

    Joseph D. DeJohn, Aug 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    394
  4. Nedu N
    Replies:
    2
    Views:
    2,150
  5. J.D. Buehls

    Request.Update to Re-Number Recordset Prob.

    J.D. Buehls, Jun 1, 2004, in forum: ASP General
    Replies:
    3
    Views:
    131
    Bob Barrows [MVP]
    Jun 1, 2004
Loading...

Share This Page