473,396 Members | 2,050 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,396 software developers and data experts.

Assigning multiple datatypes to array

I've got a DataTable, see? I'm pulling it from a stored procedure, dig? I've
gotta push it to an array for calculating certain columns, then spit it to a
web page. With me so far? The datacolumns are dates, doubles, strings, man.
How do I store all the different datatypes in a multidimensional array,
dude? Am I looking at a jagged array? Nope, all answers point to another way
of calulating this drek, right? I'm doing this becuase the Stored Procedure
can't handle the calculation, in case you're wondering why I just don't do
it that way.

I look forward to your answer with anticipation.

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion
Nov 15 '05 #1
6 5118
Steve Wasser <se******@hotmail.com> wrote:
I've got a DataTable, see? I'm pulling it from a stored procedure, dig? I've
gotta push it to an array for calculating certain columns, then spit it to a
web page. With me so far? The datacolumns are dates, doubles, strings, man.
How do I store all the different datatypes in a multidimensional array,
dude? Am I looking at a jagged array? Nope, all answers point to another way
of calulating this drek, right? I'm doing this becuase the Stored Procedure
can't handle the calculation, in case you're wondering why I just don't do
it that way.


Just use an array of type object - I don't see why you need a
multidimensional array though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
I was just assuming I'd need a [,] array for rows and colums. I'll need to
cherry-pick the columns I want to add (like the 3rd, 4th, 5th columns will
be summed, all others will left alone) To do that, I would have to reference
a specific column/row, wouldn't I?

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Steve Wasser <se******@hotmail.com> wrote:
I've got a DataTable, see? I'm pulling it from a stored procedure, dig? I've gotta push it to an array for calculating certain columns, then spit it to a web page. With me so far? The datacolumns are dates, doubles, strings, man. How do I store all the different datatypes in a multidimensional array,
dude? Am I looking at a jagged array? Nope, all answers point to another way of calulating this drek, right? I'm doing this becuase the Stored Procedure can't handle the calculation, in case you're wondering why I just don't do it that way.


Just use an array of type object - I don't see why you need a
multidimensional array though.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #3
"Steve Wasser" <se******@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
I was just assuming I'd need a [,] array for rows and colums. I'll need to
cherry-pick the columns I want to add (like the 3rd, 4th, 5th columns will
be summed, all others will left alone) To do that, I would have to reference a specific column/row, wouldn't I?

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion


Well then, why not just iterate through the rows of original datatable?
All the facility you need - iterating, indexing, modifying, is all there
already.

If you're going to create extra data structures, use them to store the
results of your calculations, and not data that is already contained in the
datatable.

Erik
Nov 15 '05 #4
"Steve Wasser" <se******@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
I was just assuming I'd need a [,] array for rows and colums. I'll need to
cherry-pick the columns I want to add (like the 3rd, 4th, 5th columns will
be summed, all others will left alone) To do that, I would have to reference a specific column/row, wouldn't I?

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion


But, if you do want to push out all your datarows to an array, you
probably want to use the DataRow.ItemArray property, which returns an array
of type object, as Jon Skeet suggested.

Erik
Nov 15 '05 #5
Two options are best,
You can either create a custom collection class of that table using only the fields you are interested in or, can create a DataTable, and then iterate through its rows or columns which ever you are working with.
Jagged arrays are not the best solution for this.

Hope this might work!
Nov 15 '05 #6
Three freaking books, and not one of them mentions the existence of a
DataRow.ItemArray property...thanks for your help, guys.

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion
"Erik Frey" <er*******@hotmail.com> wrote in message
news:uW**************@TK2MSFTNGP11.phx.gbl...
"Steve Wasser" <se******@hotmail.com> wrote in message
news:10*************@corp.supernews.com...
I was just assuming I'd need a [,] array for rows and colums. I'll need to cherry-pick the columns I want to add (like the 3rd, 4th, 5th columns will be summed, all others will left alone) To do that, I would have to reference
a specific column/row, wouldn't I?

--
Steve Wasser
http://xdissent.com
the journal of contrarian social discourse and neurotic opinion


But, if you do want to push out all your datarows to an array, you
probably want to use the DataRow.ItemArray property, which returns an

array of type object, as Jon Skeet suggested.

Erik

Nov 15 '05 #7

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

Similar topics

3
by: elhombrebala | last post by:
With this script I can force the user to select the checkbox befor continuing, but now I have a menu with lots of radio unputs and I woul like the user to select at least 2 of them; how can I check...
1
by: Jenny | last post by:
Hi, Can I create an array of tags by assigning same name to these tags? For example, I have two <p> tags with the same name t1. But document.all.b.value=document.all.t.length does not...
14
by: Eric Bantock | last post by:
Very basic question I'm afraid. Once an array has been declared, is there a less tedious way of assigning values to its members than the following: myarray=8; myarray=3; myarray=4; myarray=0;...
15
by: Iced Crow | last post by:
In C# I know that you can use delegates to assing multiple addresses of sub and functions to a delegate and have it fire multiple procedures... How do I do this in VB? I only know of assigning...
2
by: circuit_breaker | last post by:
Hi, Is there's a built-in object inside of mySQL that hold its various datatypes? As an example, I'd like to populate an array with the following values: "BOOL",...
5
by: michal | last post by:
hi guys, i thought you might be interested in a nice JSON class which converts ASP datatypes (basic datatypes, dictionaries, recordsets, ...) into JSON so that javascript can easily understand it...
6
by: Jeff | last post by:
Dear experts! ..NET 2.0 I'm trying to make an array containg multiple datatypes. This array will consist of 3 items (string, string, integer): my first try was this, (of course it fails)...
2
by: Ray D. | last post by:
I want to set matrix A with the values below, but it produced a syntax error when I try to compile the commented code. I was told to use a for loop to do this (as shown below), but that really...
37
by: miken32 | last post by:
In PHP, if a function returns an array it's fairly common to capture its return values like this: <?php list($foo, $bar, $baz) = some_function_that_return_an_array(); ?> In Javascript, would...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
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...
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...

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.