dataset datable

G

Guest

Hi all,

I have a dataset which I pass back from my webservice to my app.
In my webservice, it looks like this:
ds.Tables["StudentTestpaper"]

I want to access the datatable in my dataset in my app after it has received
the dataset.
How do I do this ? I tried:
int intTest = (int)ds.Tables["StudentTestpaper"].Rows[0][0];
DateTime strDT2 = (DateTime)ds.Tables["StudentTestpaper"].Rows[0][8];

This doesn't work.

TIA,
andrew
 
G

Guest

The error message:

Object reference is not set to an instance of an object.

Thanks

Eliyahu Goldin said:
what's the error?

Eliyahu

Andrew said:
Hi all,

I have a dataset which I pass back from my webservice to my app.
In my webservice, it looks like this:
ds.Tables["StudentTestpaper"]

I want to access the datatable in my dataset in my app after it has
received
the dataset.
How do I do this ? I tried:
int intTest = (int)ds.Tables["StudentTestpaper"].Rows[0][0];
DateTime strDT2 = (DateTime)ds.Tables["StudentTestpaper"].Rows[0][8];

This doesn't work.

TIA,
andrew
 
E

Eliyahu Goldin

ok, something in your reference doesn't exist. The dataset? The table? The
row? The cell? If you set a breakpoint, you should find out what is missing.
Could be there is a problem in the way how you pass the dataset in the
webservice?

Eliyahu

Andrew said:
The error message:

Object reference is not set to an instance of an object.

Thanks

Eliyahu Goldin said:
what's the error?

Eliyahu

Andrew said:
Hi all,

I have a dataset which I pass back from my webservice to my app.
In my webservice, it looks like this:
ds.Tables["StudentTestpaper"]

I want to access the datatable in my dataset in my app after it has
received
the dataset.
How do I do this ? I tried:
int intTest = (int)ds.Tables["StudentTestpaper"].Rows[0][0];
DateTime strDT2 = (DateTime)ds.Tables["StudentTestpaper"].Rows[0][8];

This doesn't work.

TIA,
andrew
 
S

sloan

You need to break it down:

DataTable dt = ds.Tables[0];
if(null!=dt)
{
DataRow dr = dt.Rows[0];
if(null!=dr)
{
//// you get the drill
}
}

With all the ordinal stuff, you might want to consider creating a strongly
typed DataSet

...
 
G

Guest

Thanks for your replies.

I changed the code to:

int aa = (int)ds.Tables[0].Rows[0][0];
DateTime strDT2 = (DateTime)ds.Tables[0].Rows[0][8];

It seems that ds.Tables["StudentTestpaper"] is not the same as ds.Tables[0]
, hmm...... I am sure that I populated my dataset in my webservice with
["StudentTestpaper"].

regards,
andrew

sloan said:
You need to break it down:

DataTable dt = ds.Tables[0];
if(null!=dt)
{
DataRow dr = dt.Rows[0];
if(null!=dr)
{
//// you get the drill
}
}

With all the ordinal stuff, you might want to consider creating a strongly
typed DataSet

...


Andrew said:
Hi all,

I have a dataset which I pass back from my webservice to my app.
In my webservice, it looks like this:
ds.Tables["StudentTestpaper"]

I want to access the datatable in my dataset in my app after it has received
the dataset.
How do I do this ? I tried:
int intTest = (int)ds.Tables["StudentTestpaper"].Rows[0][0];
DateTime strDT2 = (DateTime)ds.Tables["StudentTestpaper"].Rows[0][8];

This doesn't work.

TIA,
andrew
 

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,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top