Adding Row and Column to the same table at the same time.

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

Guest

I have a datatable that was created within a dataset. I dynamically add columns to the table as I add data. Previously added rows probably did not have data for the column that is being added. Since I’m added rows and maybe columns at the same time, what is column content for rows that have been added earlier? Are the data rows for the newly add colum equal nulls or zero length?



Thanks
 
what is column content for rows that have been added earlier?

Nothing.

You have to define your columns first, then add rows to the table. The cells
will be null until you add something (assuming you allowed nulls in the
column.

Ken

Larry Bird said:
I have a datatable that was created within a dataset. I dynamically add
columns to the table as I add data. Previously added rows probably did not
have data for the column that is being added. Since I'm added rows and
maybe columns at the same time, what is column content for rows that have
been added earlier? Are the data rows for the newly add colum equal nulls
or zero length?
 
Larry,
In addition to KC's comments.
Are the data rows for the newly add column equal nulls or zero length?
When you tried it, what were the values in those columns?

Seeing as it sounds like you already having a working solution, when you add
a new column what value shows up in previous rows?

I would expect it is dependant on the DataColumn being added. If you add an
Auto Increment column that the value for previous rows will be an auto
incremented amount, if you have a computed column, it will be the value of
the Expression. If you have set the DefaultValue it will be the default
value, if you did not set the default value, it will be the DefaultValue's
default (DBNULL.Value), unless of course you have AllowDBNull is false...

Hope this helps
Jay

Larry Bird said:
I have a datatable that was created within a dataset. I dynamically add
columns to the table as I add data. Previously added rows probably did not
have data for the column that is being added. Since I'm added rows and
maybe columns at the same time, what is column content for rows that have
been added earlier? Are the data rows for the newly add colum equal nulls
or zero length?
 
Back
Top