Solved

500pts: Extracting data from a table object?

Posted on 2006-07-20
9
194 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now