adding data row

  • Thread starter Thread starter RickN
  • Start date Start date
R

RickN

I have a dataset with a datatable that has an identity column. There are no
relationships.

I'm trying to directly add a datarow to the datatable using existing data
from the database, including a value for the identity column. It won't let
me because it says the indexer is read only.

What can I do to get around this? It doesn't seem to want to allow me to
unset any of the column or table properties to allow for this.

Thanks,
RickN
 
Rick,

Identity values are entered by the Database and not the user. So you can't assign a value to that column at run time.

I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 
If I pass the dataset to a dataadapter with a stored procedure to return
some existing rows, it is able to insert the rows into the datatable with
the existing identity column value. It seems all I am trying to do is
replicate the same process manually and it seems I should be able to do it
somehow.

RickN


Hussein Abuthuraya said:
Rick,

Identity values are entered by the Database and not the user. So you
can't assign a value to that column at run time.
I hope this helps!


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
 
Identity values in a DataTable for newly added rows means nothing to the database. They are just place holders and the actual value that is inserted in the database is
determined by the Server. If you want to assign a value your self, then you shouldn't use a column type of "Identity".


Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
 
Back
Top