Home All Groups Group Topic Archive Search About

Determine whether a field in recordset is a Identity Field

Author
26 Oct 2006 12:43 PM
Bart Steur
Hi,

I'm using VB6 and I want to know which Column in the recordset is the
Identity Column (if any).

I've a SQL Server 2000 table. It has 5 colums, the first one is the Identity
Column.
Now I want to recognize this column in VB6 using ADO 2.8. I used the
recordset fields collection, but it does not contain that information.

The reason I want to know this is because I want to copy a record in that
table.

I tried : INSERT INTO myTable SELECT * FROM myTable WHERE myID = 822

but then it responds with: An explicit value for the identity column in
table 'tblAttachments' can only be specified when a column list is used and
IDENTITY_INSERT is ON.

But I want it to insert the copied record with an new identity. So I want to
use :

INSERT INTO myTable (fld02, fld03,fld04, fld05) SELECT fld02, fld03, fld04,
fld05 FROM myTable WHERE myID = 822

Any ideas on both issues?

thx,

Bart

AddThis Social Bookmark Button