Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dataset update prob

Reply
Thread Tools

dataset update prob

 
 
drishtik
Guest
Posts: n/a
 
      09-08-2003
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




 
Reply With Quote
 
 
 
 
Ian
Guest
Posts: n/a
 
      09-12-2003
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
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio prob that's more than a sound card prob LineOut Computer Support 3 04-19-2008 02:30 PM
Firefox update prob Martin ©¿©¬ @nohere.net Computer Support 0 12-02-2007 07:08 PM
NAV update file prob Robert Baer Computer Information 7 02-07-2005 05:43 PM
Printer prob and also networking prob Gareth not NLL or anybody else. Computer Support 2 01-02-2004 07:48 PM
Xp prob after update lee Computer Support 2 09-29-2003 07:05 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57