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. 3 6729
"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?
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
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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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
|
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...
|
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...
|
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.
----------------------------------------------------------------------------
----
|
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...
| |
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...
|
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.
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |