DataTable from Array

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

I have a need to create a generic DataTable using data in a 2D array of
strings (I do not have direct access to the database, and am given the data
via another program that I do not have control over).

Is there a quicker, more efficient way to do it besides creating an empty
DataTable and creating and appending DataRows?

Thanks,
pagates
 
pagates,

Not really, but it would be easy to create a function that takes the
array, the columns you want each element in the array to be populated with,
and then create the data table. You could then reuse this over and over.

Hope this helps.
 
I suppose the same theory would be true for a DataAdapter...

Thanks,
pagates

Nicholas Paldino said:
pagates,

Not really, but it would be easy to create a function that takes the
array, the columns you want each element in the array to be populated with,
and then create the data table. You could then reuse this over and over.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

pagates said:
Hi All,

I have a need to create a generic DataTable using data in a 2D array of
strings (I do not have direct access to the database, and am given the
data
via another program that I do not have control over).

Is there a quicker, more efficient way to do it besides creating an empty
DataTable and creating and appending DataRows?

Thanks,
pagates
 
Do you mean creating a data adapter which wraps around a two-dimensional
array? I don't know that it would, because a data adapter would require
commands to query/update/insert/delete records.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

pagates said:
I suppose the same theory would be true for a DataAdapter...

Thanks,
pagates

Nicholas Paldino said:
pagates,

Not really, but it would be easy to create a function that takes the
array, the columns you want each element in the array to be populated
with,
and then create the data table. You could then reuse this over and over.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

pagates said:
Hi All,

I have a need to create a generic DataTable using data in a 2D array of
strings (I do not have direct access to the database, and am given the
data
via another program that I do not have control over).

Is there a quicker, more efficient way to do it besides creating an
empty
DataTable and creating and appending DataRows?

Thanks,
pagates
 
Hi Nicholas,

I was just "thinking out loud."

I am adapting a project that currently uses Odbc-based stuff
(OdbcDataReader, OdbcDataAdapter, etc.) to be able to instead use the data
returned in a 2-D string array instead. A lot less elegant, and we won't
know column names, etc. (at least, without doing some "magic" with queries).

Basically, its a new project based upon old technology. I used the Odbc
classes to "get it working" (the stuff that relies on the data) and now need
to backfill with the old stuff to get the actual data.

Thanks,
Paul
Nicholas Paldino said:
Do you mean creating a data adapter which wraps around a two-dimensional
array? I don't know that it would, because a data adapter would require
commands to query/update/insert/delete records.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

pagates said:
I suppose the same theory would be true for a DataAdapter...

Thanks,
pagates

Nicholas Paldino said:
pagates,

Not really, but it would be easy to create a function that takes the
array, the columns you want each element in the array to be populated
with,
and then create the data table. You could then reuse this over and over.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Hi All,

I have a need to create a generic DataTable using data in a 2D array of
strings (I do not have direct access to the database, and am given the
data
via another program that I do not have control over).

Is there a quicker, more efficient way to do it besides creating an
empty
DataTable and creating and appending DataRows?

Thanks,
pagates
 
Back
Top