Storing array of double. There must be an easier way.

From: David (David_at_blackdeck.com)
Date: 12/17/04


Date: Fri, 17 Dec 2004 12:29:04 -0800

I want to create an application that gathers some scientific data and stores
it in an SQL Server database. The application uses C# and ado.net.

I would like to gather a sample of data, which consists of 5,000 doubles.
Ideally, I would store the data in a single field in a database. One record
stores one collection of data. So it has such fields as time of collection,
settings from the data collection apparatus, and then one field that stores
the collected data.

What's the easiest way to do this?

Because it has 5,000 doubles in the record, it seems like I will have to use
an image field. Not good, because of the overhead, but something I can live
with.

So I have a stored procedure that takes as one of its arguments the data.
At some point, I have to say something like
cmd.Parameters["@CollectedData"]=mycollecteddata.

And I think mycollecteddata has to be an ArrayList, right?

Which means I have a variable

double[] orignialcollecteddata.

So I want to convert double[] originalcollecteddata to ArrayList
mycollecteddata.

At this point, I find myself wishing for C++, which is something I don't
wish for often. But I wish this because I can't think of anything to do
except:

mycollecteddata=new ArrayList(40000);
for (int i=0;i<5000;i++)
{byte[] onedouble;
 onedouble=System.Bitconverter.GetyBytes(collecteddata[i]);
 for(int j=0;j<8;j++)
 {mycollecteddata[i*8+j]=onedouble[j];
 }
}

That seems like a whole lot of conversions for what I want to do.

So, in summary, I want to throw an array of doubles into a SQLServer database.

The easiest way I can think of to do this is to

1. Create an arraylist big enough to hold each of the bytes of the array of
doubles.
2. For each data point in the original, convert that value into bytes.
3. Copy each of the bytes to a corresponding object in the ArrayList.
4. Pass the ArrayList to an ado sqlCommand object as an argument that will
be saved in an image file.

It just seems like there ought to be a better way. Is there?

Thanks for any insight into how to store large quantities of floating point
data.



Relevant Pages

  • Re: Need Advice on Linux vs. Windows for a Database-Driven Web Application
    ... We recently hired sales reps in several cities in the US ... > and Canada to maintain our displays in stores and to take orders from ... > in a database that we could access from the Head Office. ... No question - the Linux based one. ...
    (comp.programming)
  • Re: Max Exchage DB size in SBS
    ... private) rather than total. ... The stores grow as necessary to house their content, ... the database will grow by 100mb. ... becomes "slack" in the database. ...
    (microsoft.public.backoffice.smallbiz2000)
  • Re: Multi phase processing
    ... I writing a perl/mysql backend to a website, ... number of pages of input, then, at the end, stores all the info on the ... all of which is taken from some data tables on the database. ... approach completely and use a decent session module that lets you ...
    (comp.lang.perl.misc)
  • Re: opinions on store and mailbox limits
    ... database store being a btree database. ... enumeration of the mailbox items. ... By splitting the stores we have lessend the problems we now ... "Exchange Storage Guy" wrote in message ...
    (microsoft.public.exchange.admin)
  • A little complex question, please help...Im a newbie
    ... database for a shoe description. ... The ID of stores are linked with the ID of the main database. ... would write the status of shoes in all my stores and the warehouse. ...
    (comp.databases.ms-access)