Connecting Tech Pros Worldwide Forums | Help | Site Map

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

=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a
#1: Nov 21 '08
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.

Jeff Johnson
Guest
 
Posts: n/a
#2: Nov 21 '08

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?


=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a
#3: Nov 21 '08

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
>
=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a
#4: Nov 21 '08

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