Autoincrement fields

  • Thread starter Thread starter mfleet1973
  • Start date Start date
M

mfleet1973

Hi.

I'm sure that this topic has been covered before but I just can't find
it so here goes.

I'm using VB.Net & SQL Server 2000.

I have a table with an Identity field of type int. I need to know the
value of the id field upon inserting the record. When I add the new
row should I update the data adapter right away? After updating the
data adapter, should I refill the dataset to get the real value of the
identity field? Is there a better way of getting the new value of the
id field? Since this is a multi-user application, it is crutial that I
get this info.

Thanks a lot.

Mike.
 
As long as you set up the dataadapter correctly this is all taken care of
for you.

However, I recommend using a uniqueidentifier column instead of an identity
column and generating the value when you create the row. This means that you
don't have the 'problem' of having to retrieve the assigned identity value.
 
Mike,

You should with OleDB and not with SQLClient.
(Assuming that you are using the complete for the adapter needed SQL
statement as used by the wizards)

However I follow as well that advice from Stephany that it is better to use
the unique indentifier and set in that by ever new row a New Guid() as
identifier

Cor
 
Hi Mike,

Is the Identity value going to be used as a foreign key on a "details" table
in a "master" / "detail" relationship?

Paul
 
Back
Top