Connecting Tech Pros Worldwide Help | Site Map

"System.Data.EnumerableRowCollection`1[System.Object]" question

  #1  
Old November 21st, 2008, 08:45 AM
=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a
I'm trying to populate a rich text box with the results of a query, thus:

private void button1_Click(object sender, EventArgs e)
{
var query
from trans in dataSet.Transaction
select new
{
trans.T_Date,
trans.T_PayeeId,
trans.T_Category,
trans.T_SubCategory,
trans.T_PayMethod,
trans.T_Amount
};
foreach (var item in query)
{
richtxbxAnalysis.Text = query.Cast<object>().ToString();
}
}

My text box is showing:

"System.Data.EnumerableRowCollection`1[System.Object]" and nothing else.

I'd appreciate advice on how to display the data requested in the query.
  #2  
Old November 21st, 2008, 07:05 PM
Jeff Johnson
Guest
 
Posts: n/a

re: "System.Data.EnumerableRowCollection`1[System.Object]" question


"Paolo" <Paolo@discussions.microsoft.comwrote in message
news:B3372BE5-F957-4FE4-A2DB-C64DAAD29F79@microsoft.com...
Quote:
richtxbxAnalysis.Text = query.Cast<object>().ToString();
Quote:
My text box is showing:
>
"System.Data.EnumerableRowCollection`1[System.Object]" and nothing else.
You're casting the query to an object and then calling ToString(). Object's
implementation of ToString() simply returns the class name. In other words,
it's doing exactly what you told it to do.

Why did you think you needed to cast to object?


  #3  
Old November 21st, 2008, 08:25 PM
=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a

re: "System.Data.EnumerableRowCollection`1[System.Object]" question


Jeremy: thanks. That gave me a data row, but, it appears, only the final row
in the dataset. I thought a simple 'select', as shown, would return all items
in the dataset (which is what I want).

"Jérémy Jeanson" wrote:
Quote:
i think you wanted code this :
>
private void button1_Click(object sender, EventArgs e)
{
var query =
from trans in dataSet.Transaction
select new
{
trans.T_Date,
trans.T_PayeeId,
trans.T_Category,
trans.T_SubCategory,
trans.T_PayMethod,
trans.T_Amount
};
foreach (var item in query)
{
richtxbxAnalysis.Text = item.ToString();
}
}
>
>
--
Jérémy JEANSON
MCP
http://jeremy.blogdns.net
>
  #4  
Old November 21st, 2008, 08:35 PM
=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a

re: "System.Data.EnumerableRowCollection`1[System.Object]" question


Jeff: most probably because I'm learning and still don't have sufficient
comprehension of LINQ/Enumerable/Anonymous Types! What I coded at least gave
me an entry in the text box. Everything else I tried gave an exception about
not being able to cast a TransactionRow to String.

"Jeff Johnson" wrote:
Quote:
"Paolo" <Paolo@discussions.microsoft.comwrote in message
news:B3372BE5-F957-4FE4-A2DB-C64DAAD29F79@microsoft.com...
>
Quote:
richtxbxAnalysis.Text = query.Cast<object>().ToString();
>
Quote:
My text box is showing:

"System.Data.EnumerableRowCollection`1[System.Object]" and nothing else.
>
You're casting the query to an object and then calling ToString(). Object's
implementation of ToString() simply returns the class name. In other words,
it's doing exactly what you told it to do.
>
Why did you think you needed to cast to object?
>
>
>
Closed Thread