473,729 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"System.Data.En umerableRowColl ection`1[System.Object]" question

I'm trying to populate a rich text box with the results of a query, thus:

private void button1_Click(o bject sender, EventArgs e)
{
var query
from trans in dataSet.Transac tion
select new
{
trans.T_Date,
trans.T_PayeeId ,
trans.T_Categor y,
trans.T_SubCate gory,
trans.T_PayMeth od,
trans.T_Amount
};
foreach (var item in query)
{
richtxbxAnalysi s.Text = query.Cast<obje ct>().ToString( );
}
}

My text box is showing:

"System.Data.En umerableRowColl ection`1[System.Object]" and nothing else.

I'd appreciate advice on how to display the data requested in the query.
Nov 21 '08 #1
3 6732
"Paolo" <Pa***@discussi ons.microsoft.c omwrote in message
news:B3******** *************** ***********@mic rosoft.com...
richtxbxAnalysi s.Text = query.Cast<obje ct>().ToString( );
My text box is showing:

"System.Data.En umerableRowColl ection`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?
Nov 21 '08 #2
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:
i think you wanted code this :

private void button1_Click(o bject sender, EventArgs e)
{
var query =
from trans in dataSet.Transac tion
select new
{
trans.T_Date,
trans.T_PayeeId ,
trans.T_Categor y,
trans.T_SubCate gory,
trans.T_PayMeth od,
trans.T_Amount
};
foreach (var item in query)
{
richtxbxAnalysi s.Text = item.ToString() ;
}
}
--
Jérémy JEANSON
MCP
http://jeremy.blogdns.net
Nov 21 '08 #3
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:
"Paolo" <Pa***@discussi ons.microsoft.c omwrote in message
news:B3******** *************** ***********@mic rosoft.com...
richtxbxAnalysi s.Text = query.Cast<obje ct>().ToString( );
My text box is showing:

"System.Data.En umerableRowColl ection`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?
Nov 21 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
3344
by: Dr Duck | last post by:
GDay all, Something seems odd to me.... I wrote a simple C# function public void bind(ref object a, ref object b, bool atob) { if(atob) b = a; else
6
5264
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> My question is how do I access the document DOM of this object in Javascript? For example, "alert(extendedhtml.innerHTML);" doesn't work and produces an unknown error. I'd like to both read and write to the document's body element's innerHTML...
6
2015
by: kobu.selva | last post by:
I was recently part of a little debate on the issue of whether constants and string literals are considered "data objects" in C. I'm more confused now than before. I was always under the understanding that only "named" storage areas(from the standard) were data objects. Since constants and string literals don't have lvalues, they can't be data objects. Yet, I was shown the first page of chapter 2 in K&R2, which states that variables...
3
8833
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I don't think I made any changes to either page other than changing the user control that creates the header). Server Error in '/myApp' Application. ---------------------------------------------------------------------------- ----
0
2673
by: JT | last post by:
This seems like it could be an asp.net bug. I am getting the following exception when I add OnSortCommand attribute to a datagrid. I have deleted the temp directories, rebooted etc and I have isolated it to the OnSortCommands presence. When I use a code behind it doesn't fire any events on the back end and the global error handler grabs it. I put together a very simple example to illustrate the problem below. If anyone has an idea of...
0
2675
by: woollymammoth | last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be an easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record is named "Try". The VB script function accessing the record value is running on a web hosting server with ASP.Net 2.0 on a web page. Result always is it "can't convert from a Field to type 'String'". Printing out the SQL variable results in...
2
3442
by: =?Utf-8?B?cmVk?= | last post by:
Hi Friends, We recently deployed our application to production and I am experiencing the below error message. Cannot access a disposed object named "System.Net.TlsStream" The error occurs when we are making a web service call to an external system (within our corporate n/w). The method is POST and the URL is over HTTPS.
3
2880
by: Michel Couche | last post by:
Hello, I have an ASP.Net application that uses the Wizard control to build a newsletter. There are three steps in the wizard. The customer's specific design data are loaded from a database in step 1 of the wizard and saved into a session variable. In step 2, when the user clicks on a button, I load the design data from the session variable and these are saved for further handling in a HashTable. The HashTable is defined in the...
14
2175
by: Ronald S. Cook | last post by:
I'm just curious how you would handle this. In the cable industry, Comcast is referred to as an "MSO" (multiple systems operator) meaning they own many cable systems. Therefore a solution must be architected to accommodate "System" as an entity. This means a table in the database named System, a class System, a web form System, etc. Since System is such a reserved word, how should we do this? To rename it "CableSystem" would bug as...
0
8913
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8761
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6016
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2162
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.