Say I have a table of companies, and a table of industries (like
automobiles, steel, computers, etc..) A company may be involved in
industries, so there's a third table- a mapping table- which just keys a
company to a specific industry. This table can have multiple rows for a
single company, since some companies can be involved in multiple industries.
Now when I display Companies in a DataGrid, I want a column that prints out
all the industries it is involved in- in a comma-separated string. So one
column's data might look like "Automobile s, Machine Tools, Aeronautics" if
there are 3 rows for that company mapping it to each of those industries.
Now the trick is, how would I accomplish this just using DataTable
expression? No real SQL, just whatever the DataColumn expression syntax has
to offer... is it possible? 1 1715
The DataColumn expression syntax is just for processing the data in that
column in that table, it isn't suited for retrieving data from other tables.
You'll have to do that in code yourself, probably after you fill your
dataset you could add a new calculated column, loop through the rows,
retrieve the industries data and synthetically create the value for the
column.
--
John Wood
Blog: http://spaces.msn.com/members/johnwood/
"MrNobody" <Mr******@discu ssions.microsof t.com> wrote in message
news:ED******** *************** ***********@mic rosoft.com... Say I have a table of companies, and a table of industries (like automobiles, steel, computers, etc..) A company may be involved in industries, so there's a third table- a mapping table- which just keys a company to a specific industry. This table can have multiple rows for a single company, since some companies can be involved in multiple
industries. Now when I display Companies in a DataGrid, I want a column that prints
out all the industries it is involved in- in a comma-separated string. So one column's data might look like "Automobile s, Machine Tools, Aeronautics"
if there are 3 rows for that company mapping it to each of those industries.
Now the trick is, how would I accomplish this just using DataTable expression? No real SQL, just whatever the DataColumn expression syntax
has to offer... is it possible? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: bob |
last post by:
I cannot seem to display any info with my Data Grid ... the online examples
I have seen 'appear' to say the same thing.
create a DataTable then simply call something like this myDataGrid.Source =
myDataTable. I'm missing something fundemental here cos I get big black
nothing.
here's some code snippets.
public class Form1 : System.Windows.Forms.Form
{
|
by: GG |
last post by:
I am trying to add a nullable datetime column to a datatable fails. I am
getting exception
DataSet does not support System.Nullable<>.
None of these works
dtSearchFromData.Columns.Add( new DataColumn( "StartDate",
typeof( DateTime? ) ) );
dtSearchFromData.Columns.Add( new DataColumn( "EndDate",
typeof( System.Nullable<DateTime>) ) );
Any ideas?
|
by: DaveP |
last post by:
im Trying to set a Datacolumn type for a new table
boolean is not working, What is the correct waty
//column.DataType = System.Type.GetType"System.Data.SqlTypes.SqlBoolean");
column.DataType = System.Type.GetType"System.Boolean"); //"System.Boolean");
tia
|
by: Manuel |
last post by:
Hi to all,
I'm trying to copy a Datacolumn from a table to another, but with this code:
destTable.Columns.Add(srcTable.Column);
I got this error:
Column 'colname' already belongs to another DataTable.
Anyone can help me?
|
by: SMH |
last post by:
Hi All,
I am currently learning .Net 2, studying for 70-528. I've hit a bit of
a brick wall with DataColumn.Expression. As I understand it, this can
be used to (For example) concatenate two columns to make a derived
column.
When I run my code, I get this error:
------------
| |
by: kirknew2SQL |
last post by:
I am new to C# and have been studying this piece of code. It loops through an Adjacency Matrix table to populate a tree view.
1. initTreeView(TreeNode N) creates a new “temp” table to hold the children for each node. Each time the table is created it has the same name “temp”. Why doesn’t the table just get over written each time?
2. In the foreach (DataRow r3 in temp.Rows) loop, if the temp table is empty like when Menu11 is reached the...
|
by: xmail123 |
last post by:
Why does this code work?
I am new to C# and have been studying this piece of code. It loops
through an Adjacency Matrix table to populate a tree view. I have two
questions about why this code works.
1. initTreeView(TreeNode N) creates a new "temp" table to hold
the children for each node. Each time the table is created it has the
same name "temp". Why doesn't the table just get over written each
time?
2. In the foreach (DataRow r3...
|
by: Ryan Liu |
last post by:
I have a program works fine in .NET 1.1 and just recompiled in .NET 2.0
without any code change. Compiles OK, but there is an exeception when
execute it.
Then I remove PK, it works all fine again.
Is this a known bug : PK on auto increase DataColumn in DataTable cause
NullReferenceException?
dcLineId = new DataColumn(LINEID_STR,
|
by: XolileWarren |
last post by:
Can anyone help?
I have a gridview and two link buttons;back and previous to navigate back and forward the page is working fine on Opera but the link button is not active when using FireFox and Internet explorer.The code is as follows
Any kind of help will be appreciated
<%@ Page Language="C#" MasterPageFile="~/mymAdmin/Main.Master" AutoEventWireup="true" CodeFile="inbox.aspx.cs" Inherits="inbox" Title="LoveLife :: Mymsta Inbox" %>
...
|
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: 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: 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...
|
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: 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();...
|
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
| |