Filling a Dataset and Dataset.WriteXML method..

S

Serdar C

hello there, i am writing a program that generates random numbers and shows
the numbers on a (x,y) chart.. i decided to use crystal reports to draw the
chart and a dataset.readxml to read data..
my problem is when i try to fil the dataset manually and type
dataset.writexml i find that theres nothing written on the xml file.. heres
the code i wrote.. please help me in this situation...

in form_load:

-----------------------------------------

ds = new DataSet();

ds.Tables.Add("numbers");

DataColumn dc = new DataColumn("number",Type.GetType("System.String"));

ds.Tables["numbers"].Columns.Add(dc);

-----------------------------------------

random number gneration and storing in dataset:

-----------------------------------------

Random r = new Random();

DataRow dr;

dr = ds.Tables[0].NewRow();

dr["numbers"] = r.NextDouble().ToString("0.#");

-----------------------------------------

and finally writing data to an xml file..

-----------------------------------------

ds.Tables[0].AcceptChanges();

ds.AcceptChanges();

ds.WriteXml("c:\\numbers.xml");

-----------------------------------------



thanx for spending your time on reading my post and have a nive year :)

p.s: visual basic 6.0 used to have a control for creating charts and i think
it was easier to use than crystal reports.. if u know a control in c# that i
can use please let me know..
 
S

Serdar C

it works now thank you so much.


Sahil Malik said:
I don't see a dt.Rows.Add in your code. Even though you do a NewRow, the row
is still detached.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


Serdar C said:
hello there, i am writing a program that generates random numbers and
shows
the numbers on a (x,y) chart.. i decided to use crystal reports to draw
the
chart and a dataset.readxml to read data..
my problem is when i try to fil the dataset manually and type
dataset.writexml i find that theres nothing written on the xml file..
heres
the code i wrote.. please help me in this situation...

in form_load:

-----------------------------------------

ds = new DataSet();

ds.Tables.Add("numbers");

DataColumn dc = new DataColumn("number",Type.GetType("System.String"));

ds.Tables["numbers"].Columns.Add(dc);

-----------------------------------------

random number gneration and storing in dataset:

-----------------------------------------

Random r = new Random();

DataRow dr;

dr = ds.Tables[0].NewRow();

dr["numbers"] = r.NextDouble().ToString("0.#");

-----------------------------------------

and finally writing data to an xml file..

-----------------------------------------

ds.Tables[0].AcceptChanges();

ds.AcceptChanges();

ds.WriteXml("c:\\numbers.xml");

-----------------------------------------



thanx for spending your time on reading my post and have a nive year :)

p.s: visual basic 6.0 used to have a control for creating charts and i
think
it was easier to use than crystal reports.. if u know a control in c# that
i
can use please let me know..
 
S

Sahil Malik

Awesome !! :)


Serdar C said:
it works now thank you so much.


Sahil Malik said:
I don't see a dt.Rows.Add in your code. Even though you do a NewRow, the row
is still detached.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik


Serdar C said:
hello there, i am writing a program that generates random numbers and
shows
the numbers on a (x,y) chart.. i decided to use crystal reports to draw
the
chart and a dataset.readxml to read data..
my problem is when i try to fil the dataset manually and type
dataset.writexml i find that theres nothing written on the xml file..
heres
the code i wrote.. please help me in this situation...

in form_load:

-----------------------------------------

ds = new DataSet();

ds.Tables.Add("numbers");

DataColumn dc = new DataColumn("number",Type.GetType("System.String"));

ds.Tables["numbers"].Columns.Add(dc);

-----------------------------------------

random number gneration and storing in dataset:

-----------------------------------------

Random r = new Random();

DataRow dr;

dr = ds.Tables[0].NewRow();

dr["numbers"] = r.NextDouble().ToString("0.#");

-----------------------------------------

and finally writing data to an xml file..

-----------------------------------------

ds.Tables[0].AcceptChanges();

ds.AcceptChanges();

ds.WriteXml("c:\\numbers.xml");

-----------------------------------------



thanx for spending your time on reading my post and have a nive year :)

p.s: visual basic 6.0 used to have a control for creating charts and i
think
it was easier to use than crystal reports.. if u know a control in c# that
i
can use please let me know..
 

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

Top