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

From: Miroslav Balaz (miroslav_balaz_at_hotmail.com)
Date: 01/03/05


Date: Mon, 3 Jan 2005 05:12:49 +0100

Hi,

You can use GetChunk & AppendChunk methods of Field (ADO) object.
How to - see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdmthgetchunk.asp

Miro Balaz

"David" <David@blackdeck.com> píše v diskusním příspěvku
news:220188C3-5712-4F78-ADA1-242A555DA2B9@microsoft.com...
>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: DataType for storing pointlist (x,y,z)?
    ... Using vb6, ado, writing to mdb format ... If I want to store an array of 3 doubles, what would be best for the data ...
    (microsoft.public.vb.database.ado)
  • DataType for storing pointlist (x,y,z)?
    ... Using vb6, ado, writing to mdb format ... If I want to store an array of 3 doubles, what would be best for the data ...
    (microsoft.public.vb.database.ado)
  • CONTAINS METHOD IN ARRAYLIST PROBLEM.
    ... My program lets the user add words to store it like a customized ... doubles up. ... getInputAdd is a String. ...
    (comp.lang.java.programmer)
  • Re: Opening CSV file with 69000 + rows in Excel using VBA
    ... Knowing now that he is willing to toss the data out you are correct. ... original assumption was the he would want to store the data, ... ADO will work great in this instance. ... "Tom Ogilvy" wrote: ...
    (microsoft.public.excel.programming)
  • Re: Float comparison
    ... any more than a stored value of type int ... In addition doubles *are* used to store exact integral values and integer types *are* used to store approximations. ... Any claim that you have stored a range when you have in fact stored the exact value that you intended to store is clearly wrong and would make error analysis impossible. ...
    (comp.lang.c)