Re: Convert a dataset to an array

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Miha Markic [MVP C#] (miha)
Date: 03/15/04


Date: Mon, 15 Mar 2004 16:00:24 +0100

Hi Alvin,

What kind of array? Object[]?
Does DataRow.ItemArray help?
You have still loop through all the rows, though.

-- 
Miha Markic [MVP C#] - DXSquad/RightHand .NET consulting & software
development
miha at rthand com www.rthand.com
Developer Express newsgroups are for peer-to-peer support.
For direct support from Developer Express, write to support@devexpress.com
Bug reports should be directed to: support@devexpress.com
Due to newsgroup guidelines, DX-Squad will not answer anonymous postings.
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:uI1gKupCEHA.2576@TK2MSFTNGP11.phx.gbl...
> I'm not trying to serialize. I'm trying to load data into a component. The
> component accepts 1D arrays. The data source is a dataset. I'd like to put
> the two together elegantly.
>
> -- 
> Regards,
> Alvin Bruney [ASP.NET MVP]
> Got tidbits? Get it here...
> http://tinyurl.com/3he3b
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:u4J1NImCEHA.3132@TK2MSFTNGP11.phx.gbl...
> > Hi Alvin,
> >
> > I am not sure what you are after.
> > DataSet can be serialized (always as XML).
> > A better result you will achieve by using this stuff:
> > True Binary Serialization And Compression of DataSets
> > http://www.eggheadcafe.com/articles/20031219.asp
> >
> > -- 
> > Miha Markic [MVP C#] - RightHand .NET consulting & software development
> > miha at rthand com
> > www.rthand.com
> >
> > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> > news:%23ywtOMlCEHA.1588@tk2msftngp13.phx.gbl...
> > > Surely, there must exist an elegant way to flatten a dataset into a 1D
> > > array. I cannot believe that the only way accomplish this is to loop
> thru
> > > the rows in the dataset. Yuck!!!
> > >
> > > This is what i tried
> > > DataSet ds = loadData();
> > > ds.Tables[0].Rows.CopyTo(str,0);   //bombout here
> > >
> > > next...
> > >
> > > DataColumnCollection dc = ds.Tables[0].Columns;
> > > string[] columns = new string[dc.Count];
> > > dc.CopyTo(columns, 0);             //bombout here
> > > strHead = String.Join(",", columns);
> > >
> > > I believe the bombout is because of the system.dbnull which a dataset
> > allows
> > > however, i'm not sure. I'd like to use one of these approaches. I
> > absolutely
> > > hate this
> > > for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
> > >     StringBuilderVal.Append(",").Append( blah blah blah Yuck!!!
> > >
> > > private DataSet loadData()
> > > {
> > >    DataSet dsTemp = new DataSet();
> > >    DataTable Tables = new DataTable();
> > >    dsTemp.Tables.Add(Tables);
> > >    dsTemp.Tables[0].Columns.Add( "test", System.Type.GetType(
> > > "System.String" ) );
> > >
> > >    for(int col = 0; col < 10; col++)
> > >    {
> > >         DataRow myRow = dsTemp.Tables[0].NewRow();
> > >         myRow[0] = col.ToString();
> > >         dsTemp.Tables[0].Rows.Add(myRow);
> > >    }
> > >    return dsTemp;
> > > }
> > >
> > > Anybody?
> > >
> > > -- 
> > > Regards,
> > > Alvin Bruney [ASP.NET MVP]
> > > Got tidbits? Get it here...
> > > http://tinyurl.com/3he3b
> > >
> > >
> >
> >
>
>


Relevant Pages

  • Re: Invoke doesnt return?!
    ... miha at rthand com www.rthand.com ... Developer Express newsgroups are for peer-to-peer support. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re:Server does not send faxes for non-administrators
    ... Windows Server 2003 Newsgroup at ... Developer newsgroups. ... I have provided the link below to access Developer ... Set objFaxServer = New FAXCOMEXLib.FaxServer ...
    (microsoft.public.windows.server.sbs)
  • Re: Malloc and recursion
    ... "sgi wrote:" above). ... how can a pointer be an index of an array? ... or is it the value pointed to by the pointer that is the index of the ... confusing world of newsgroups etc. can u be my guide here? ...
    (comp.lang.c)
  • RE: Adprep /forestprep failing
    ... I suggest you ask for developer support: ... developer newsgroups: ... Microsoft Online Partner Support ... | was modified or added is the AD attribute UID: ...
    (microsoft.public.windows.server.migration)
  • Re: set focus on a specific record after adding new record
    ... Continuing to come back to these newsgroups to ... We try to help the *developer* with technical issues to ... what s/he wants to do can't be done with Access. ... there will be requests for his schema to be included in a response. ...
    (microsoft.public.access.tablesdbdesign)