dataset update prob

D

drishtik

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
 
I

Ian

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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top