"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:O4**************@TK2MSFTNGP02.phx.gbl...
"Rod" <Ro**********@Hotmail.comwrote in message
news:e0**************@TK2MSFTNGP05.phx.gbl...
>But how do I sort out the identity field.
Can you explain a bit more what you mean by "sort out" the identity
field...?
When you add a new row to a SQL Server table which contains an identity
field, you don't actually provide a value for that field - SQL Server
generates it for you automatically... If you need to know what the
automatically generated ID of the new record is, use SELECT
SCOPE_IDENTIY() within the same SQL batch...
http://www.google.co.uk/search?hl=en...DENTITY+&meta=
OK I can first create a new row in the SQL table and get the ID, but because
some fields are set to Not Null I have to give them data. But the user has
not yet provided any data.
I could first create the new row in the DataSet without an identity, get the
data for the row (forcing the user to fill in the not null fields) and then
create a new row in the SQL table now I have all the data. I was just
feeling uncomfortable about having a row in my Dataset without an identity
so I was wondering what the proper way of doing it is.
PS thanks for the SELECT SCOPE_IDENTIY tip.