Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2005, 12:44 PM
Registered User
 
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use Rows from a DataTable to Create Columns In oth

Use Rows from one DataTable to Create Columns In another!!!

Hello experts,

I have two datatables

DataTable dtblAuthors = dtblAuthors ( "Authors " )
DataTable dbtlBooks = dbtlBooks ("Books")

I need to add columns to DataTable dtblAuthors like so

dcolCloumn = new DataColumn( "Book1" )
dtblAuthors.columns.add(dcolCloumn )


dcolCloumn2 = new DataColumn( "Book2" )
dtblAuthors.columns.add(dcolCloumn2 )....E.T.C

The twist here is that I need to accomplish this by adding the columns to DataTable dtblAuthors using rows from DataTable dbtlBooks.

so DataTable dtblAuthors could have the following fields;
ID AUTHORNAME
 1 John Doe
 2 Jane Block
 3 Just Wright

and DataTable dbtlBooks could have the following fields
ID BOOKNAME AUTHORID
 1. C#.NET 1
 2. ASP.NET 1
 3. FLASH 1
 4. C++ 2
 5 DESIGN 3
 6. PERL 2

Essentially, where dbtlBooks.AUTHORID = dtblAuthors.AUTHORID I want to create a BOOKNAME column in dtblAuthors to a maximum of six columns.

DEFAULT VALUE = NONNE
So my resulting DataTable would be;
ID AUTHORNAME BOOK1 BOOK2 BOOK3 BOOK4 BOOK5 BOOK6
 1. John Doe C#.NET ASP.NET FLASH NONNE NONNE NONNE
 2. Jane Block C++ PERL
 3. Just Wright DESIGN


NONNE<---------IS THE DEFAULT VALUE IF THERE ISN'T A BOOK FOR THE COLUMN

how do I accomplish this?

thankx








Similar Threads
Thread Thread Starter Forum Replies Last Post
Backcolor for separate rows DataRow in Datatable i mikeka VS.NET 2002/2003 0 July 3rd, 2006 08:03 PM
Rows 2 Columns kilika Oracle 0 October 14th, 2005 01:16 PM
Adding rows, AND column(s) to existing datatable cliffd64 VB.NET 2002/2003 Basics 1 August 18th, 2005 06:50 AM
Getting the Top 5 Rows from a datatable flyin General .NET 9 June 14th, 2004 08:36 AM
adding rows to datatable forkhead ADO.NET 2 March 18th, 2004 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.