473,395 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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;
oCmd.Connection.Open();
dr = oCmd.ExecuteReader();
DataSet[] dsUpdate = new DataSet[nTerminals];
int i = 0;
while (dr.Read())
{
try
{
using (StringReader sr = new StringReader(dr.GetString(4)))
{
dsUpdate[i].ReadXml(sr);
}
}
catch(Exception exc)
{
}
i++;
}
oCmd.Connection.Close();

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

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 6074
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Haobin | last post by:
Hi everyone, I have an ArrayList whose members are classes. These classes are derived from a same base class. The base class has a floating point array and a string. How do I access each element in...
6
by: Michael Rodriguez | last post by:
What is the proper way to declare and initialize an array of datasets? Would it go like this: private DataSet myDataSets; DataSet ds1 = new DataSet(); // initialize the dataset DataSet...
4
by: Alpha | last post by:
I have a small Window application and through out the different forms I create a different dataset. At the begining I used the Tools to drag and drop the SqlDataAdapter, connection and dataset...
33
by: Peace | last post by:
I am having trouble writing code to turn an array into a delimited string. Dim splitout As String splitout = Join(DataArray(rows, columns), " ") rows and columns are integers representing rows...
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
16
by: Luqman | last post by:
Is it recommended to use datasets in ASP.Net 2.0 / VS.Net 2005 ? Best Regards, Luqman
4
by: Ronald S. Cook | last post by:
I've always used untyped datasets. In a Microsoft course, it walks through creating typed datasets and harps on the benefits. It has you drag all these things around ..wizard, wizard, wizard......
25
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as...
0
by: S.Tedeschi | last post by:
Hi all; as posted some days ago, I'm converting an on-line app; I used to heavily rely on strongly-typed DataSets directly dropped onto pages, and so viewed by code(-behind) as well. In the next...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.