471,350 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Array of datasets....

Hi all,

I am trying to do the following:

I have a db column that stores xml inside
I want to create one dataset for each field with xml ( this means that I
don't know how many datasets I will have...) anyway I had a great idea, and
array of datasets, but it's not working...here is the code:

OdbcCommand oCmd = new OdbcCommand("SELECT * FROM tb_s57_terminals WHERE
class = 7",oConn);
OdbcDataReader dr;
dr = oCmd.ExecuteReader();
DataSet[] dsUpdate = new DataSet[nTerminals];
int i = 0;
while (dr.Read())
using (StringReader sr = new StringReader(dr.GetString(4)))
catch(Exception exc)

the var nTerminals is a count to the fields on the database that have class

The problem is an object reference not set to an instance of an object....

It catchs it on the try.... can someone tell me why?
Feb 3 '06 #1
1 5660
"Diogo Alves - Software Developer"
<Di*************************@discussions.microsoft .com> wrote in message
news:6F**********************************@microsof t.com...
Hi all,
DataSet[] dsUpdate = new DataSet[nTerminals]; dsUpdate[i].ReadXml(sr); The problem is an object reference not set to an instance of an object....

I think your error is due to the fact that you never actually CREATE a
dataset at each index of dsUpdate.
DataSet[] dsUpdate = new DataSet[nTerminals];
only creates the array itself - it does not fill each index with instances
of datasets.
Just above your call to ReadXml, try adding:

dsUpdate[i] = new DataSet();

Adam Clauss

Feb 3 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Michael Rodriguez | last post: by
33 posts views Thread by Peace | last post: by
9 posts views Thread by GaryDean | last post: by
4 posts views Thread by Ronald S. Cook | last post: by
25 posts views Thread by Penelope Dramas | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.