Ask a Question related to ASP.NET General, Design and Development.
-
S. Justin Gengo #1
Re: Add array of rows to DataTable
Frank,
I don't know of any way to add an array of rows. I believe that you'll have
to iterate through the array and add each one at a time:
DataTable.Rows.Add(SingleDataRow)
But to clear all rows is pretty easy:
DataTable.Rows.Clear()
Justin
"frank" <frank@frank.com> wrote in message
news:uvZOEEuSDHA.872@TK2MSFTNGP12.phx.gbl...> How do I add an array of DataRows (i.e. DataRow[]) to a DataTable?
>
> Also, how do I remove all rows from a DataTable?
>
>
S. Justin Gengo Guest
-
How to retrieve first 50 rows , next 50 rows and so on in Informix
Hi All Is there any equivalent command for SET ROWCOUNT or LIMIT in INFORMIX to get the first 50rows, next 50 rows and so on if query returns... -
Modify rows in DataTable
Hi Steve, Suppose you want to change text in some column depending on the data in data source, you can do it in ItemDataBound event. Dim... -
DataTable from an array of objects returned from a webservice
I have the "simple" problem of wanting to take an array of objects I get from a webservice and turning them into a DataTable. The following is my... -
Select rows where other related rows don't exist
I would like to select rows from a table where another related row in the same table doesn't exist and the relation key is more than 1 column. ... -
comparing rows in a multidimensional array
how can i compare rows (3 or more rows) in a multidiemensional array? they all contain numeric values, i need to find its similar values and unique... -
frank #2
Re: Add array of rows to DataTable
"S. Justin Gengo" <gengoj@krause.com> wrote in message
news:vh86nleiv5f01a@corp.supernews.com...have> "frank" <frank@frank.com> wrote in message
> news:uvZOEEuSDHA.872@TK2MSFTNGP12.phx.gbl...> Frank,> > How do I add an array of DataRows (i.e. DataRow[]) to a DataTable?
> >
> > Also, how do I remove all rows from a DataTable?
> >
> >
>
> I don't know of any way to add an array of rows. I believe that you'llOK, I've done that but now it says "This row already belongs to another> to iterate through the array and add each one at a time:
>
> DataTable.Rows.Add(SingleDataRow)
table". I know you can't move a DataRow from one collection to another if it
belongs to another - so I tried dtFiltered.ImportRow(dr).
When I do it that way, it appears to add the rows without any problem, but
when it comes to actually referencing and using the data later on.
If I try:
Console.Write(dr[0].ToString() + "\r\n")
It says "Cannot find column 0".
Any ideas?
I tried this to see if it would let me use the Add method, but it didn't> But to clear all rows is pretty easy:
>
> DataTable.Rows.Clear()
work.
frank Guest
-
S. Justin Gengo #3
Re: Add array of rows to DataTable
Frank,
If you're referring to the row that was just added to the table then the row
object might get cleared when it's imported. That's my best guess.
Can you refer to it in full? (i.e. DataTableImportedTo.Rows(0)(0).ToString)
Sorry, but I don't know the equivilant in C#. It should be pretty close to
the same though...
Justin
"frank" <frank@frank.com> wrote in message
news:%23INi8XuSDHA.1552@TK2MSFTNGP10.phx.gbl...it> "S. Justin Gengo" <gengoj@krause.com> wrote in message
> news:vh86nleiv5f01a@corp.supernews.com...> have> > "frank" <frank@frank.com> wrote in message
> > news:uvZOEEuSDHA.872@TK2MSFTNGP12.phx.gbl...> > Frank,> > > How do I add an array of DataRows (i.e. DataRow[]) to a DataTable?
> > >
> > > Also, how do I remove all rows from a DataTable?
> > >
> > >
> >
> > I don't know of any way to add an array of rows. I believe that you'll>> > to iterate through the array and add each one at a time:
> >
> > DataTable.Rows.Add(SingleDataRow)
> OK, I've done that but now it says "This row already belongs to another
> table". I know you can't move a DataRow from one collection to another if> belongs to another - so I tried dtFiltered.ImportRow(dr).
>
> When I do it that way, it appears to add the rows without any problem, but
> when it comes to actually referencing and using the data later on.
>
> If I try:
>
> Console.Write(dr[0].ToString() + "\r\n")
>
> It says "Cannot find column 0".
>
> Any ideas?
>>> > But to clear all rows is pretty easy:
> >
> > DataTable.Rows.Clear()
> I tried this to see if it would let me use the Add method, but it didn't
> work.
>
>
S. Justin Gengo Guest
-
frank #4
Re: Add array of rows to DataTable
"S. Justin Gengo" <gengoj@krause.com> wrote in message
news:vh88d7ab0hpne0@corp.supernews.com...you'll> "frank" <frank@frank.com> wrote in message
> news:%23INi8XuSDHA.1552@TK2MSFTNGP10.phx.gbl...> > "S. Justin Gengo" <gengoj@krause.com> wrote in message
> > news:vh86nleiv5f01a@corp.supernews.com...> > > "frank" <frank@frank.com> wrote in message
> > > news:uvZOEEuSDHA.872@TK2MSFTNGP12.phx.gbl...
> > > > How do I add an array of DataRows (i.e. DataRow[]) to a DataTable?
> > > >
> > > > Also, how do I remove all rows from a DataTable?
> > > >
> > > >
> > > Frank,
> > >
> > > I don't know of any way to add an array of rows. I believe thatif> > have> >> > > to iterate through the array and add each one at a time:
> > >
> > > DataTable.Rows.Add(SingleDataRow)
> > OK, I've done that but now it says "This row already belongs to another
> > table". I know you can't move a DataRow from one collection to anotherbut> it> > belongs to another - so I tried dtFiltered.ImportRow(dr).
> >
> > When I do it that way, it appears to add the rows without any problem,row>> > when it comes to actually referencing and using the data later on.
> >
> > If I try:
> >
> > Console.Write(dr[0].ToString() + "\r\n")
> >
> > It says "Cannot find column 0".
> >
> > Any ideas?
> >> >> > > But to clear all rows is pretty easy:
> > >
> > > DataTable.Rows.Clear()
> > I tried this to see if it would let me use the Add method, but it didn't
> > work.
> >
> If you're referring to the row that was just added to the table then theDataTableImportedTo.Rows(0)(0).ToString)> object might get cleared when it's imported. That's my best guess.
>
> Can you refer to it in full? (i.e.to>
> Sorry, but I don't know the equivilant in C#. It should be pretty closeThanks for the help, but I found and solved the problem.> the same though...
For archiving purposes, here's what it was:
When I used the ImportRow method it doesn't actually create any DataColumns
in the DataTable and as DataColumns are required to reference the data (even
though it *was* there) I could actually access it.
I resolved the issue by creating the DataColumns first, before using
ImportRow.
frank Guest



Reply With Quote

