Solved

500pts: Extracting data from a table object?

Posted on 2006-07-20
9
197 Views
Last Modified: 2010-04-16
Hi..

Can anyone help, I seem to be having a problem getting data from a table.. I have a table and if i do

? myData.Table.Rows.Count

I get 1, so data is there...

I have tried various things like

I tried myData.Table.Columns["TOTAL"]

but there is no property VALUE for example...

Can anyone suggest what i am doing wrong?

Thanks in advance

Ian


0
Comment
Question by:ianinspain
9 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17145524
Hi ianinspain,

what object is myData : DataTable, DataTableCollection?

Apresto
0
 
LVL 29

Assisted Solution

by:Gautham Janardhan
Gautham Janardhan earned 250 total points
ID: 17145545
assuming that you are using datatable collection

the problem is that by stating Datatable.Table.columns[0]
u get the first column element

what u got to do is
myData.Table.Rows[i]["TOTAL"]
i is the row index i.e first row would be
myData.Table.Rows[0]["TOTAL"]
0
 

Author Comment

by:ianinspain
ID: 17145800
Thanks gauthampj,

That sort of works.. I get this

? myData.Table.Rows[0]["BO"]
{130.1}
    System.ValueType: {System.Double}
    Epsilon: 4.94065645841247E-324
    m_value: 130.1
    MaxValue: 1.7976931348623157E+308
    MinValue: -1.7976931348623157E+308
    NaN: NaN
    NegativeInfinity: -Infinity
    PositiveInfinity: +Infinity

But i really need just the value, i did try ToString but that didn't give the details either...

0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 3

Expert Comment

by:BBK_
ID: 17146127
myData.Table.Rows[0][0].ToString(), this should give you the first value in the first column
If it has value then , I think there may not be any column named "TOTAL"
0
 

Author Comment

by:ianinspain
ID: 17146237
No it works... but doing ToString doesn't give me the value..

0
 
LVL 3

Expert Comment

by:BBK_
ID: 17146253
U mean myData.Table.Rows[0][0] has value, but
myData.Table.Rows[0][0].ToString() throws error, rite?
0
 
LVL 3

Accepted Solution

by:
BBK_ earned 250 total points
ID: 17146321
Just a sample code


DataTable d = new DataTable();
d.Columns.Add("Test", typeof(System.String));
DataRow r = d.NewRow();
r[0] = "TESTCOLUMN";
d.Rows.Add(r);

MessageBox.Show(d.Rows[0][0].ToString());
0
 

Author Comment

by:ianinspain
ID: 17146927
Thanks BBK, yes i did try this... here is what i get.... If the column is a string then no probs....  But my column is a Double

? response.Data.Tables[0].Rows[0][1]
{0.0}
    System.ValueType: {System.Double}
    Epsilon: 4.94065645841247E-324
    m_value: 0.0
    MaxValue: 1.7976931348623157E+308
    MinValue: -1.7976931348623157E+308
    NaN: NaN
    NegativeInfinity: -Infinity
    PositiveInfinity: +Infinity
? response.Data.Tables[0].Rows[0][1].ToString
<overloaded>
    ToString: ((System.Double)((response.Data.Tables[0].Rows[0].get_Item(1)))).ToString+0 // method+offset
    ToString: ((System.Double)((response.Data.Tables[0].Rows[0].get_Item(1)))).ToString+0 // method+offset
    ToString: ((System.Double)((response.Data.Tables[0].Rows[0].get_Item(1)))).ToString+0 // method+offset
    ToString: ((System.Double)((response.Data.Tables[0].Rows[0].get_Item(1)))).ToString+0 // method+offset
0
 

Author Comment

by:ianinspain
ID: 17146986
ahh .. thnaks.. I got it

Double.Parse( response.Data.Tables[0].Rows[0][1].ToString())

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question