473,416 Members | 1,557 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Translating Columns As Rows In a DataSet

The code i'm writing is using VB .NET and is for a web service returning a
dataset, which is in turn to be used by an ASP .NET application displaying a
datagrid.

I'm currently populating a datagrid using a "select top 1 column 1, column2,
column3 from tblTable" statement. As there will only ever be one row
returned I want to be able to to switch the column names to be row1 and the
column values to be row 2

i.e. select house, street, state from table addresses

16, Washington Way, NYC

to be displayed as

ELEM VAL
------- -------
House 16
Street Washington Way
State NYC
To make this translation easiest i want to be able to do this using my web
service. Any ideas as to how i can manipulate my dataset in such a way?

TIA,
Matt
Nov 21 '05 #1
6 2518
Hi,

http://www.windowsformsdatagridhelp....8-2b9e762316ab

Ken
------------------
"Jumping Matt Flash" <ju**************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
The code i'm writing is using VB .NET and is for a web service returning a
dataset, which is in turn to be used by an ASP .NET application displaying a
datagrid.

I'm currently populating a datagrid using a "select top 1 column 1, column2,
column3 from tblTable" statement. As there will only ever be one row
returned I want to be able to to switch the column names to be row1 and the
column values to be row 2

i.e. select house, street, state from table addresses

16, Washington Way, NYC

to be displayed as

ELEM VAL
------- -------
House 16
Street Washington Way
State NYC
To make this translation easiest i want to be able to do this using my web
service. Any ideas as to how i can manipulate my dataset in such a way?

TIA,
Matt

Nov 21 '05 #2
Many thanks Ken,

However i've continued to have issues with your code for some reason. As i'm
retrieving only the one row i've tried using the following: Draw is a web
service which returns a dataset according to inString

Dim dataTables = Accessor.Draw(inString)
Dim dt2 As New DataTable("Translated")
dataTables.Tables.Add(dt2)

'Loop table(0) translating the data
Dim dr As DataRow = dataTables.Tables(1).NewRow
For y As Integer = 0 To dataTables.Tables(0).Columns.Count - 1
dr(y) = dataTables.Tables(0).Rows(0).Item(y)
Next
dataTables.Tables(1).Rows.Add(dr)

This just returns the following error however:

Exception Details: System.IndexOutOfRangeException: Cannot find column 0.

Source Error:

Line 34: Dim dr As DataRow = dataTables.Tables(1).NewRow
Line 35: For y As Integer = 0 To
dataTables.Tables(0).Columns.Count - 1
Line 36: dr(y) = dataTables.Tables(0).Rows(0).Item(y)
Line 37: Next
Line 38: dataTables.Tables(1).Rows.Add(dr)
TIA

Matt

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uH****************@TK2MSFTNGP12.phx.gbl...
Hi,

http://www.windowsformsdatagridhelp....8-2b9e762316ab

Ken
------------------
"Jumping Matt Flash" <ju**************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
The code i'm writing is using VB .NET and is for a web service returning a
dataset, which is in turn to be used by an ASP .NET application displaying
a
datagrid.

I'm currently populating a datagrid using a "select top 1 column 1,
column2,
column3 from tblTable" statement. As there will only ever be one row
returned I want to be able to to switch the column names to be row1 and
the
column values to be row 2

i.e. select house, street, state from table addresses

16, Washington Way, NYC

to be displayed as

ELEM VAL
------- -------
House 16
Street Washington Way
State NYC
To make this translation easiest i want to be able to do this using my web
service. Any ideas as to how i can manipulate my dataset in such a way?

TIA,
Matt

Nov 21 '05 #3
Hi,

I am not sure why you are getting the error. However I would stop
using late binding it might help find your error.

Dim dataTables as dataset = Accessor.Draw(inString)
Ken
-----------------
"Jumping Matt Flash" <ju**************@gmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Many thanks Ken,

However i've continued to have issues with your code for some reason. As i'm
retrieving only the one row i've tried using the following: Draw is a web
service which returns a dataset according to inString

Dim dataTables = Accessor.Draw(inString)
Dim dt2 As New DataTable("Translated")
dataTables.Tables.Add(dt2)

'Loop table(0) translating the data
Dim dr As DataRow = dataTables.Tables(1).NewRow
For y As Integer = 0 To dataTables.Tables(0).Columns.Count - 1
dr(y) = dataTables.Tables(0).Rows(0).Item(y)
Next
dataTables.Tables(1).Rows.Add(dr)

This just returns the following error however:

Exception Details: System.IndexOutOfRangeException: Cannot find column 0.

Source Error:

Line 34: Dim dr As DataRow = dataTables.Tables(1).NewRow
Line 35: For y As Integer = 0 To
dataTables.Tables(0).Columns.Count - 1
Line 36: dr(y) = dataTables.Tables(0).Rows(0).Item(y)
Line 37: Next
Line 38: dataTables.Tables(1).Rows.Add(dr)
TIA

Matt

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:uH****************@TK2MSFTNGP12.phx.gbl...
Hi,

http://www.windowsformsdatagridhelp....8-2b9e762316ab

Ken
------------------
"Jumping Matt Flash" <ju**************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
The code i'm writing is using VB .NET and is for a web service returning a
dataset, which is in turn to be used by an ASP .NET application displaying
a
datagrid.

I'm currently populating a datagrid using a "select top 1 column 1,
column2,
column3 from tblTable" statement. As there will only ever be one row
returned I want to be able to to switch the column names to be row1 and
the
column values to be row 2

i.e. select house, street, state from table addresses

16, Washington Way, NYC

to be displayed as

ELEM VAL
------- -------
House 16
Street Washington Way
State NYC
To make this translation easiest i want to be able to do this using my web
service. Any ideas as to how i can manipulate my dataset in such a way?

TIA,
Matt


Nov 21 '05 #4
"Jumping Matt Flash" <ju**************@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
The code i'm writing is using VB .NET and is for a web service
returning a dataset, which is in turn to be used by an ASP .NET
application displaying a datagrid.
From the little I know of WebServices, returning a DataSet is a
Bad Idea. Web Services are meant for cross-platform interoperability
(can hardly type it, let alone pronounce it!), and only .Net clients can
seriously make use of the amorphous DataSet.
Anyhow ...
I'm currently populating a datagrid using a "select top 1 column 1,
column2, column3 from tblTable" statement. As there will only ever
be one row returned I want to be able to to switch the column names
to be row1 and the column values to be row 2


This really shouldn't be an issue for the WebService.
Return your DataSet with one row and, containing the data, and pull
the item "names" out of the Column Names. Let the Presentation layer
(the ASP.Net thing) get all het up about how to display the thing.

If you make the WebService too complicated, you'll kick yourself
when you start trying to pass the same data back in again and have
to "unpick" all your meticulous rearranging.

Regards,
Phill W.
Nov 21 '05 #5
Phill,
From the little I know of WebServices, returning a DataSet is a
Bad Idea.
In my opinion only true as the next rule is true as well.
Web Services are meant for cross-platform interoperability
(can hardly type it, let alone pronounce it!), and only .Net clients can
seriously make use of the amorphous DataSet.


However when we tell that we are talking about .Net programs, than there is
again cross-platform interoperability.

A dataset is very nice to use in a webservice you know.

Just my thought.

Cor
Nov 21 '05 #6
Jumping Matt

Although it is possible in the an aspnet application to use a webservice,
are you in my idea overdoing it.

If you use a webservice from somebody else it has a lot of sense. However
now are you everytime visiting your webserver to get information, that you
can get direct. In my opinion a little bit inefficient operation that only
creates more clients.

However just my thought,

Cor
Nov 21 '05 #7

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

Similar topics

3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
2
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
5
by: David Wender | last post by:
I want to create a dataview with a sort on multiple columns. However, when I use FindRows, I only want to search some of the columns, not all. Is this possible? I have not been able to make it...
4
by: Mortar | last post by:
i need a datagrid with 2 header columns. The top one might have 1 column spanning 5 columns of the header row below it. what is the best way to do this? Could i have 2 datatables...1 filling the...
4
by: Jeff | last post by:
I am stuck on trying to generate two columns headers for a datagrid on form load. I can use a datatable as the datasource and get the results I want, but I want to set different column widths and...
2
by: PulkitZery | last post by:
Hello, I am trying to create a Dataset and save it to an XML file. I have one column “JobID” for which I have set the autoincrement property to true. Here is the function that creates and save the...
0
by: anureddy | last post by:
help me how to add datagridview columns to another table,using windowsapplications. and set the displaymember and value member datagridviewcomboboxcolumn. i used this below code but that not...
3
by: ASPnewb1 | last post by:
I am currently filling a dataTable then adding this table to a dataset, setting the dataset to the Gridview's datasource. If I set the Gridview to generate columns automatically it will fill the...
1
by: Mark Baldwin | last post by:
Steven Thanks for your reply, however the typed datasets are defined in the web service and there seems to way to open the partial class code window - double clicking on the design surface does...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
agi2029
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,...
0
isladogs
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...

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.