Solved

500pts: Extracting data from a table object?

Posted on 2006-07-20
9
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

623 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